PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCareers
|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

  • Compute Earliest Bus Arrival - Apple (medium)
  • Find the Extra Edge - Apple (hard)
  • Rotate a Matrix In Place - Apple (medium)
  • Encode and Rebuild a Binary Tree - Apple (hard)
  • Wrap Matching Substrings in Bold Tags - Apple (medium)
Apple logo
Apple
Mar 1, 2026, 12:00 AM
Machine Learning Engineer
Onsite
Coding & Algorithms
2
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.

Comments (0)

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 7,500+ real questions from top companies.

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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.