Implement permutations and image retrieval

Quick Overview

This question evaluates algorithmic implementation and computational thinking across combinatorics, image processing, and vector similarity—specifically testing permutation generation, 2D convolution with explicit boundary handling, and nearest-neighbor retrieval for image embeddings.

Implement permutations and image retrieval

Company: Apple

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

The coding portion included several short exercises for a vision-focused ML role: 1. Given an array of distinct integers, return all possible permutations. 2. Implement a basic grayscale image filter. The input is a 2D integer matrix and a fixed 3 x 3 kernel. Produce the filtered image using convolution, and state clearly how you handle boundary cells. 3. Given a query image embedding and a gallery of image embeddings, return the index of the most similar image. You may use cosine similarity or Euclidean distance, but explain the complexity of your approach and how you would scale it beyond a brute-force scan. Assume standard helper functions for vector math and valid input sizes.

Quick Answer: This question evaluates algorithmic implementation and computational thinking across combinatorics, image processing, and vector similarity—specifically testing permutation generation, 2D convolution with explicit boundary handling, and nearest-neighbor retrieval for image embeddings.

|Home/Coding & Algorithms/Apple
Apple logo
Apple
Mar 1, 2026, 12:00 AM
mediumMachine Learning EngineerOnsiteCoding & Algorithms
18
0

The coding portion included several short exercises for a vision-focused ML role:

  1. Given an array of distinct integers, return all possible permutations.
  2. Implement a basic grayscale image filter. The input is a 2D integer matrix and a fixed 3 x 3 kernel. Produce the filtered image using convolution, and state clearly how you handle boundary cells.
  3. Given a query image embedding and a gallery of image embeddings, return the index of the most similar image. You may use cosine similarity or Euclidean distance, but explain the complexity of your approach and how you would scale it beyond a brute-force scan.

Assume standard helper functions for vector math and valid input sizes.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...