PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Apple

Implement permutations and image retrieval

Last updated: Apr 16, 2026

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.

  • medium
  • Apple
  • Coding & Algorithms
  • Machine Learning Engineer

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.

Related Interview Questions

  • Minimum Cells to Bridge a Magic Grid - Apple (hard)
  • Find Common Prefix Across Strings - Apple (easy)
  • Find Minimum Processing Rate - Apple
  • Compute Earliest Bus Arrival - Apple (medium)
  • Find the Extra Edge - Apple (hard)
|Home/Coding & Algorithms/Apple

Implement permutations and image retrieval

Apple logo
Apple
Mar 1, 2026, 12:00 AM
mediumMachine Learning EngineerOnsiteCoding & Algorithms
5
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...

Browse More Questions

More Coding & Algorithms•More Apple•More Machine Learning Engineer•Apple Machine Learning Engineer•Apple Coding & Algorithms•Machine Learning Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.