
Apple Interview Questions
41 real coding interview questions recently asked at Apple, spanning Arrays and Strings, Trees and Graphs and Design and System Coding, with a real difficulty tag and a direct LeetCode link for every question.
By DevsUnite · 41 Problems
Total Problems: 41Difficulty Levels:EasyMediumHard
Given an array and a target, find the two indices whose values sum to the target, typically solved in a single pass using a hash map that stores each value's complement as it's seen. It requires no advanced technique, which is exactly the point — it's a fast, low-friction warm-up used to confirm a candidate can reach for a hash map instead of defaulting to a brute-force O(n^2) nested loop.
Find all unique triplets in an array that sum to zero. The standard approach sorts the array, then for each element uses a two-pointer sweep over the remaining elements, carefully skipping duplicate values to avoid repeated triplets in the output. It extends the simpler two-pointer/two-sum pattern into a triplet setting and tests whether a candidate can handle the deduplication logic correctly, which is where most candidates lose points.
Given a collection of intervals, merge all overlapping ones. The standard approach sorts intervals by start time, then does a single linear pass, extending the current merged interval whenever the next one overlaps and starting a new one otherwise. It's a foundational interval problem that shows up across many companies because interval merging underlies a large family of harder scheduling and calendar-style questions.
A classic easy-level stack problem: determine whether a string of brackets is validly matched and nested. It tests the fundamental insight that a stack naturally models nested, last-in-first-out matching — pushing opening brackets and popping/comparing on closing ones. Despite its simplicity, it's a reliable early-round filter for whether a candidate reaches for the right data structure immediately rather than over-engineering a solution.
Compute, for each index, the product of all array elements except the one at that index, without using division. The standard O(1)-extra-space solution builds a running prefix product and running suffix product in two passes, multiplying them together for the final answer. It tests array manipulation and space-optimization thinking — specifically whether a candidate can avoid the naive division-based shortcut and still hit optimal time and space.
Given a list of strings, group the ones that are anagrams of each other. The typical solution hashes each string to a canonical key (either its sorted characters or a fixed-length character-count signature) and groups strings sharing a key in a hash map. It's a straightforward but reliable test of whether a candidate reaches for the right canonicalization strategy and understands the tradeoffs between sorting-based and counting-based keys.
Find the length of the longest substring without repeating characters, the canonical sliding-window problem: maintain a window with two pointers and a hash map/set tracking the last-seen index of each character, jumping the left pointer forward whenever a repeat is found. It's one of the most fundamental sliding-window problems in interviewing and is often used to confirm a candidate can move beyond brute-force substring enumeration to a linear-time two-pointer approach.
Given a string and an integer k, find the length of the longest substring that can be made to consist of a single repeated character by changing at most k characters. The solution is a sliding window that tracks the count of the most frequent character within the window; the window is valid as long as (window size - count of most frequent character) <= k, shrinking from the left otherwise. It's a meaningful step up from basic sliding-window problems since it requires tracking a running frequency count inside the window rather than just window boundaries.
Given an elevation map, compute how much water it can trap after rain — the water trapped at each index equals the shorter of the tallest bars to its left and right, minus its own height. It's solvable with two pointers in O(1) extra space, with a monotonic stack, or with two precomputed max-prefix/max-suffix arrays, making it a great vehicle for comparing multiple valid techniques in one interview. Its breadth of companies asking it reflects that it's one of the most widely used checks of two-pointer/array reasoning in the entire interview circuit.
This asks for the maximum profit from a single buy and sell of one share, given a sequence of daily prices. The optimal solution is a single pass that tracks the minimum price seen so far and the best profit achievable by selling at the current price. Despite being an easy problem, it's a useful check for whether a candidate defaults to an unnecessary O(n^2) pairwise comparison or immediately sees the one-pass greedy/DP formulation.
Count the number of contiguous subarrays that sum to exactly k. The efficient solution uses a running prefix sum alongside a hash map counting how many times each prefix-sum value has occurred, since a subarray sums to k exactly when the difference between two prefix sums equals k. It's a strong test of the prefix-sum-plus-hash-map pattern, a technique that generalizes to many other subarray-counting problems.
Rotate an n x n matrix 90 degrees clockwise in place. The common technique is to transpose the matrix (swap elements across the diagonal) and then reverse each row, though a layer-by-layer four-way swap also works. It's a compact test of in-place matrix manipulation and geometric/index reasoning without needing any extra data structure.
Given a researcher's citation counts, compute their h-index — the largest h such that at least h papers have at least h citations each. It tests whether a candidate can sort the array (or use counting sort for a linear-time variant) and reason precisely about the threshold condition, including edge cases where no papers or all papers qualify. It's a good signal for translating a somewhat abstract, real-world-sounding metric definition into a precise algorithmic condition.
A hard problem: given a target word and a list of words to avoid clashing with, find the shortest possible abbreviation of the target that doesn't match any abbreviation of the other words. Abbreviation length counts each letter left unreplaced as 1 and each replaced run of letters as 1, so the shortest abbreviation comes from replacing as many characters as possible, not as few. It tests whether a candidate can combine bitmasking (representing which letters of the target stay unabbreviated) with backtracking or brute-force enumeration over subsets, then efficiently check each candidate abbreviation against every other word. It's a strong signal for handling combinatorial search under a nontrivial constraint-checking function.
A binary-search problem on an array that was sorted then rotated at an unknown pivot; the task is to find the minimum element in O(log n). It tests whether a candidate can adapt standard binary search by comparing the middle element against the boundaries to decide which half is unsorted (and thus contains the pivot/minimum), rather than falling back to a linear scan. It's a common stepping stone toward harder rotated-array search variants.
A binary-search problem: find a target value's index in a rotated sorted array in O(log n) time. It tests whether a candidate can identify which half of the array around the midpoint is properly sorted at each step, then decide whether the target falls within that sorted half or the other one. Its wide reach across companies reflects how well it isolates genuine binary-search intuition from candidates who only know the textbook sorted-array version.
A classic backtracking problem: generate all permutations of a list of distinct integers. It tests whether a candidate can build a recursive decision tree — choosing one unused element at each level, recursing, then undoing the choice (backtracking) — and manage a visited/used-elements structure correctly. It's frequently used as an accessible entry point into recursion and backtracking before harder constrained-search problems.
Log in to save your progress, favorites, and notes to your account.
Frequently asked questions
What coding interview questions does Apple ask?
This page tracks 41 real, recently reported Apple coding interview questions, organized by topic: Arrays and Strings, Trees and Graphs and Design and System Coding.
How many Apple interview questions are on this list?
41 questions in total: 5 Easy, 28 Medium, and 8 Hard, each linked to its real LeetCode problem page.
Is it free to use?
Yes. Browsing every problem on this page is completely free, with no account required. Creating a free DevsUnite account lets you save your checked-off progress, star favorites, and add personal notes that sync across devices.
Do I need an account to track my progress?
You can read and solve every problem without logging in. An account is only required to mark a problem as done, star it, or add a note. Those actions save to your account instead of resetting on refresh.