Apple Software Engineer Coding & Algorithms Interview Questions
Practice the exact questions companies are asking right now.
Solve interval, grid-fill, and heap tasks
You are asked to solve the following algorithmic problems. Problem 1: Concurrent users from online intervals You are given n inclusive time intervals ...
Solve three easy algorithm problems
You are given three independent algorithmic tasks. For each one, explain your approach (no need to run code). 1) Merge two sorted lists (integers inst...
Implement deep clone for complex objects
Implement a deep-clone function for nested objects in JavaScript (or a language of your choice) without using JSON serialization or third-party librar...
Design a rolling five-minute hit counter
Design an in-memory hit counter that supports: ( 1) recordHit(timestamp) to log an event, and ( 2) getCountLast5Minutes(now) to return the number of e...
Implement rotation, LRU cache, streaming median, cycle detection
Complete the following coding tasks. For each, provide code, justify time/space complexity, and describe edge cases: 1) Image rotation: Given an n×n i...
Sort and merge string lists by length
Given two unsorted lists of strings, return a single list sorted by ascending string length. Specify your tie-breaking rule for equal-length strings (...
Compute minimum required meeting rooms
Given a list of meeting time intervals [start, end) for many events, determine the minimum number of rooms required so no meetings overlap in the same...
Implement DFS for connected components
Given an undirected graph with n nodes (1 ≤ n ≤ 200, 000) and an edge list, implement depth-first search to compute (a) the number of connected compon...
Design card deck with shuffle and order
Design a playing-card deck library with two methods: shuffle() to return a uniformly random permutation of a standard 52-card deck, and order() to ret...
Refactor rock–paper–scissors for config and ties
Refactor an existing Rock–Paper–Scissors tournament with three robot players so that the number of rounds is configurable and the system also tracks t...
Find top-k frequent elements efficiently
Given an array (or stream) of integers and an integer k, return any ordering of the k most frequent values. Implement a solution using a heap and disc...
Compute top three scores per student
You are given a list of (student_id, score) records. Return, for each student, their highest three scores in descending order. First, describe and imp...
Compute island size in grid
Given an m x n binary matrix grid of 0s (water) and 1s (land), where an island is a group of 1s connected 4-directionally, implement sizeOfIsland(grid...
Design a snapshotable key-value store
Design and implement a snapshotable key–value map supporting the following APIs: - S(key, value): set the current value of a string key to a string va...
Maximize funds with capital-gated projects
You start with initial funds W and may undertake at most K projects. Each project i has a required capital C[i] and yields profit P[i]; you can only s...