# Apple Coding Interview Questions: 41 LeetCode Problems

> 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.

Canonical: https://devsunite.com/resources/faang-interview-questions/apple
Last updated: 2026-11-22

## Apple Coding Interview Questions

By DevsUnite · Total problems: 41 · Difficulty levels: Easy, Medium, Hard

## Arrays and Strings

- [Two Sum](https://leetcode.com/problems/two-sum) (LeetCode, Easy)
  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.
- [3Sum](https://leetcode.com/problems/3sum) (LeetCode, Medium)
  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.
- [Merge Intervals](https://leetcode.com/problems/merge-intervals) (LeetCode, Medium)
  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.
- [Valid Parentheses](https://leetcode.com/problems/valid-parentheses) (LeetCode, Easy)
  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.
- [Product of Array Except Self](https://leetcode.com/problems/product-of-array-except-self) (LeetCode, Medium)
  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.
- [Group Anagrams](https://leetcode.com/problems/group-anagrams) (LeetCode, Medium)
  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.
- [Longest Substring Without Repeating Characters](https://leetcode.com/problems/longest-substring-without-repeating-characters) (LeetCode, Medium)
  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.
- [Longest Repeating Character Replacement](https://leetcode.com/problems/longest-repeating-character-replacement) (LeetCode, Medium)
  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.
- [Trapping Rain Water](https://leetcode.com/problems/trapping-rain-water) (LeetCode, Hard)
  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.
- [Best Time to Buy and Sell Stock](https://leetcode.com/problems/best-time-to-buy-and-sell-stock) (LeetCode, Easy)
  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.
- [Subarray Sum Equals K](https://leetcode.com/problems/subarray-sum-equals-k) (LeetCode, Medium)
  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 Image](https://leetcode.com/problems/rotate-image) (LeetCode, Medium)
  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.
- [H-Index](https://leetcode.com/problems/h-index) (LeetCode, Medium)
  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.
- [Minimum Unique Word Abbreviation](https://leetcode.com/problems/minimum-unique-word-abbreviation) (LeetCode, Hard)
  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.
- [Find Minimum in Rotated Sorted Array](https://leetcode.com/problems/find-minimum-in-rotated-sorted-array) (LeetCode, Medium)
  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.
- [Search in Rotated Sorted Array](https://leetcode.com/problems/search-in-rotated-sorted-array) (LeetCode, Medium)
  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.
- [Permutations](https://leetcode.com/problems/permutations) (LeetCode, Medium)
  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.

## Trees and Graphs

- [Number of Islands](https://leetcode.com/problems/number-of-islands) (LeetCode, Medium)
  A grid graph-traversal problem: count connected components of '1' cells using DFS, BFS, or Union-Find, being careful with boundary checks and marking visited cells so you don't recount. It's one of the most common entry points into grid-based graph problems and is often used as a warm-up before harder multi-source or Union-Find variants. The core signal is whether a candidate can translate a 2D grid into an implicit graph and correctly implement flood-fill without off-by-one or infinite-loop bugs.
- [Lowest Common Ancestor of a Binary Tree](https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree) (LeetCode, Medium)
  This asks for the lowest common ancestor of two nodes in a general (non-BST) binary tree, solved with a recursive DFS that returns the found node upward once either target is located in a subtree. The elegant part is recognizing that if both left and right recursive calls return non-null, the current node is the LCA. It's a clean test of recursive tree thinking and correctly propagating and combining results from subtree calls.
- [Course Schedule](https://leetcode.com/problems/course-schedule) (LeetCode, Medium)
  Given prerequisite pairs, this problem asks whether all courses can be finished, which is equivalent to detecting a cycle in a directed graph. Candidates typically solve it with Kahn's algorithm (in-degree tracking and a queue) for topological sort, or with DFS using a three-color (unvisited/visiting/visited) scheme to catch back edges. It tests fundamental graph modeling skills: representing prerequisites as an adjacency list and correctly distinguishing cycle detection from simple reachability.
- [Sum Root to Leaf Numbers](https://leetcode.com/problems/sum-root-to-leaf-numbers) (LeetCode, Medium)
  Given a binary tree where each root-to-leaf path represents a number (digits along the path), sum all such numbers. It tests standard DFS/preorder traversal skills, specifically carrying an accumulated value down each recursive call and only adding to the total once a leaf is reached. It's a good check on whether a candidate handles tree recursion state correctly rather than conflating per-node and per-path values.
- [Check Completeness of a Binary Tree](https://leetcode.com/problems/check-completeness-of-a-binary-tree) (LeetCode, Medium)
  Determine whether a binary tree is a complete binary tree: every level fully filled except possibly the last, which must be filled left to right. It tests whether a candidate can use level-order (BFS) traversal, including null children as placeholders, and detect that once a null is seen, no further non-null nodes should appear. It's a solid check on tree-property reasoning distinct from more common traversal-order problems.
- [Serialize and Deserialize Binary Tree](https://leetcode.com/problems/serialize-and-deserialize-binary-tree) (LeetCode, Hard)
  A design problem: encode a binary tree into a string and reconstruct an identical tree from that string, typically via a preorder traversal with explicit null markers, or a BFS-based level encoding. The candidate must design a format that's unambiguous enough for deserialization to rebuild structure without extra information. Interview relevance frequently maps to data persistence (serializing structured data for storage or transmission and reliably reconstructing it), which is why it shows up across companies handling tree-like or hierarchical data on disk or over the wire.
- [Bus Routes](https://leetcode.com/problems/bus-routes) (LeetCode, Hard)
  A hard graph problem: given bus routes as sets of stops, find the minimum number of buses needed to travel from a source stop to a target stop. It tests whether a candidate can reframe the problem as BFS over buses (not stops), building a graph where routes are connected if they share a stop, since naive stop-by-stop BFS is far less efficient. It's a strong signal for graph-modeling creativity, since the natural-seeming approach isn't the efficient one.
- [Vertical Order Traversal of a Binary Tree](https://leetcode.com/problems/vertical-order-traversal-of-a-binary-tree) (LeetCode, Hard)
  Given a binary tree, group node values by vertical column, ordered top to bottom and, within the same row and column, by ascending value. It tests whether a candidate can perform a BFS or DFS while tracking (row, column) coordinates for each node, then apply a precise multi-key sort (column, then row, then value) to the collected results. The tricky tie-breaking rule for nodes at the same position is what makes this a meaningfully harder variant of ordinary tree traversal.
- [Flood Fill](https://leetcode.com/problems/flood-fill) (LeetCode, Easy)
  A foundational grid-traversal problem: starting from a given cell, recolor every connected cell of the same original color using DFS or BFS, analogous to the paint-bucket tool in image editors. It's usually a warm-up used to confirm a candidate can correctly implement grid traversal with visited-state tracking and boundary checks before moving on to harder graph or matrix problems in the same interview.
- [Word Ladder](https://leetcode.com/problems/word-ladder) (LeetCode, Hard)
  Word Ladder models words as nodes in an implicit graph, connecting two words if they differ by exactly one letter, and asks for the shortest transformation sequence from a start word to an end word via BFS. Because the graph isn't given explicitly, candidates must generate neighboring words on the fly (e.g., by trying all 26 letter substitutions at each position) and use a word dictionary/set for O(1) membership checks and visited tracking. Its practical relevance in interviews often ties to NLP transformations (reasoning about minimal edit-style paths between text tokens), which is one reason it recurs in ML-adjacent interview loops.
- [Coin Change](https://leetcode.com/problems/coin-change) (LeetCode, Medium)
  A canonical unbounded-knapsack dynamic programming problem: given coin denominations and a target amount, find the minimum number of coins needed to make that amount (or determine it's impossible). The standard solution builds a bottom-up DP array where each amount's answer depends on smaller amounts reduced by each coin denomination. It's often used to gauge whether a candidate can correctly set up and reason about a 1D DP recurrence and its base cases, a foundational skill for many other DP problems.
- [Longest Increasing Subsequence](https://leetcode.com/problems/longest-increasing-subsequence) (LeetCode, Medium)
  Given an integer array, find the length of the longest strictly increasing subsequence. It tests whether a candidate can move from the straightforward O(n^2) dynamic-programming solution to the O(n log n) approach using binary search over a maintained array of smallest tail values for increasing subsequences of each length. It's a well-known bar for whether a candidate can optimize a DP solution using an auxiliary data structure rather than stopping at the first correct-but-slower approach.
- [House Robber](https://leetcode.com/problems/house-robber) (LeetCode, Medium)
  A dynamic-programming problem: given houses in a row with money amounts, find the maximum sum you can rob without robbing two adjacent houses. It tests basic 1D DP with the recurrence dp[i] = max(dp[i-1], dp[i-2] + nums[i]), often solvable with O(1) space using two rolling variables. Apple is reported to follow up by probing the circular variant (House Robber II, where the first and last houses are adjacent), which tests whether a candidate can decompose a circular constraint into two linear subproblems.

## Design and System Coding

- [LRU Cache](https://leetcode.com/problems/lru-cache) (LeetCode, Medium)
  A design problem requiring O(1) get and put operations with least-recently-used eviction, implemented by combining a hash map (for O(1) lookup) with a doubly linked list (for O(1) reordering and eviction from either end). This exact structure underlies real inference key-value caches; it's reportedly one of the most frequently asked design questions at companies building LLM inference systems, since eviction policy for a bounded cache maps directly onto managing GPU memory for attention KV caches. It's a strong test of whether a candidate can compose two data structures to get O(1) across every required operation, not just some of them.
- [Word Break](https://leetcode.com/problems/word-break) (LeetCode, Medium)
  Given a string and a dictionary of words, this asks whether the string can be segmented into a space-separated sequence of dictionary words. The standard solution is DP where dp[i] indicates whether the prefix of length i can be segmented, checking all dictionary words as potential suffixes ending at each position. It's a foundational string-DP problem and often a stepping stone to the harder Word Break II, testing whether a candidate can define and fill a boolean DP array correctly.
- [Top K Frequent Elements](https://leetcode.com/problems/top-k-frequent-elements) (LeetCode, Medium)
  Requires counting element frequencies with a hash map, then selecting the k most frequent using either a heap (O(n log k)) or bucket sort by frequency (O(n)). It's a common building block for ML preprocessing workflows (identifying the most frequent tokens, features, or events in a dataset before further processing), which is part of why it recurs in ML-adjacent interview loops. The bucket-sort approach in particular tests whether a candidate recognizes that frequency is bounded by array length and can exploit that to avoid a full sort.
- [Maximum Profit in Job Scheduling](https://leetcode.com/problems/maximum-profit-in-job-scheduling) (LeetCode, Hard)
  This is a weighted interval scheduling problem: sort jobs by end time, then use dynamic programming where each state answers 'what's the best profit using jobs up to index i,' combined with binary search to quickly find the latest job that doesn't overlap with the current one. It tests whether a candidate can recognize a scheduling problem as DP-with-binary-search rather than reaching for a greedy or brute-force solution, and it's a natural extension of simpler interval-merging problems into an optimization setting.
- [Median of Two Sorted Arrays](https://leetcode.com/problems/median-of-two-sorted-arrays) (LeetCode, Hard)
  A hard problem: find the median of two sorted arrays in O(log(min(m,n))) time. It tests whether a candidate can go beyond the trivial O(m+n) merge approach to a binary-search-on-partitions technique, correctly reasoning about partition boundaries and edge cases like empty arrays or odd/even combined length. It's one of the most well-known hard-tier binary search problems and a strong filter for candidates who can handle intricate boundary logic under pressure.
- [Search a 2D Matrix](https://leetcode.com/problems/search-a-2d-matrix) (LeetCode, Medium)
  Given a matrix where each row is sorted and the first element of each row is greater than the last element of the previous row, determine whether a target value exists, in better than linear time. It tests whether a candidate recognizes the matrix can be treated as a single sorted array via index arithmetic (mapping a 1D binary-search index to a 2D row/column), rather than doing a row-by-row or nested search. It's a clean check on translating binary search intuition across a mapped coordinate space.
- [Time Based Key-Value Store](https://leetcode.com/problems/time-based-key-value-store) (LeetCode, Medium)
  A design problem requiring a hash map from key to a list of (timestamp, value) pairs, plus binary search to efficiently find the value at or before a queried timestamp. It tests whether a candidate can combine a hash map with binary search rather than resorting to a linear scan, since values are appended with strictly increasing timestamps. It's a natural fit for companies dealing with versioned or time-stamped storage; Anthropic and OpenAI probe it in the context of retrieving the right version of a model checkpoint by timestamp, a real pattern in ML infrastructure.
- [Design Hit Counter](https://leetcode.com/problems/design-hit-counter) (LeetCode, Medium)
  This design problem asks for a counter that records hits with timestamps and can report the number of hits in the past 300 seconds. It's typically implemented with a queue (or a fixed-size circular buffer of timestamp/count pairs) that evicts entries falling outside the trailing time window as new hits arrive. It tests whether a candidate can design a data structure for a sliding time window under both single-hit and (in a common follow-up) batched-hit conditions.
- [Design Add and Search Words Data Structure](https://leetcode.com/problems/design-add-and-search-words-data-structure) (LeetCode, Medium)
  A design problem: build a data structure supporting adding words and searching with a wildcard '.' that can match any single letter. It tests whether a candidate can extend a trie with DFS-based search that branches over all children when a wildcard is encountered, rather than requiring an exact-match traversal. It's a natural harder follow-up to the basic Trie problem and checks whether a candidate can adapt a known structure to a new requirement.
- [Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator) (LeetCode, Medium)
  A design problem: implement an iterator over a BST's in-order traversal with next() and hasNext(), where next() should run in average O(1) time and the iterator should use O(h) extra memory rather than flattening the whole tree upfront. The standard solution uses an explicit stack that's incrementally pushed further down the left spine as needed, simulating in-order traversal lazily. It tests whether a candidate can convert a typically-recursive traversal into an iterative, resumable one under a real memory constraint.
- [Implement Queue using Stacks](https://leetcode.com/problems/implement-queue-using-stacks) (LeetCode, Easy)
  A design problem: implement a FIFO queue using only two LIFO stacks. It tests whether a candidate understands the classic technique of using one stack for pushes and lazily transferring elements to a second stack (reversing their order) only when the second stack is empty and a pop/peek is needed. It's a compact, well-known signal for whether a candidate can reason about amortized time complexity rather than just correctness.

## How to prepare for the Apple coding interview with this list

These 41 questions are real, recently reported Apple coding interview problems, each linked to its LeetCode page. The biggest group is Arrays and Strings with 17 questions, so start there if you are short on time.

Solve each question without hints first, say your approach out loud as you would in the interview, then read the note under the problem to see what it tests. Mark questions done here to keep your progress across devices.

### Questions by topic

| Topic | Questions |
| --- | --- |
| Arrays and Strings | 17 |
| Trees and Graphs | 13 |
| Design and System Coding | 11 |

### Difficulty split

- Easy: 5
- Medium: 28
- Hard: 8

### Where the questions are hosted

- LeetCode: 41

## Real interview experiences

First-hand interview stories from DevsUnite, plus DSA sheets to practice with.

- [Apple interview process](https://devsunite.com/interview-process/apple-interview-process) - Every stage of the Apple software engineer interview, with sources
- [My Amazon SDE-1 Interview Experience as a Fresher (2026)](https://devsunite.com/blog/my-amazon-sde-1-interview-experience-as-a-fresher-2026) - Amazon interview experience
- [My Zepto SDE-1 Interview Experience as a Fresher (2026)](https://devsunite.com/blog/my-zepto-sde-1-interview-experience-as-a-fresher-2026) - Zepto interview experience
- [Getting Hired at Sarvam AI: My Fresher Interview Story](https://devsunite.com/blog/getting-hired-at-sarvam-ai-my-fresher-interview-story) - Sarvam AI interview experience
- [My Swiggy SDE-1 Android Interview Experience](https://devsunite.com/blog/my-swiggy-sde-1-android-interview-experience) - Swiggy interview experience
- [Striver's A2Z DSA Sheet](https://devsunite.com/resources/dsa-sheets/striver-a2z)
- [Rohit Negi DSA Sheet (Coder Army)](https://devsunite.com/resources/dsa-sheets/rohit-negi)

## 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.

## Related

- [FAANG Interview Questions](https://devsunite.com/resources/faang-interview-questions)
- [All interview prep resources](https://devsunite.com/resources)
