InterviewKata
Interview preparation

Apple interview problems, by pattern

All 69 problems from Apple's six-month LeetCode list (7 Easy, 53 Medium, 9 Hard), grouped by the pattern that solves them. 67 are solved on this site: open one to see which pattern to choose and why, the approach, the code with a line-by-line explanation, and a player that steps through the code on LeetCode's own example. Easy warm-ups and SQL/JavaScript problems link to LeetCode.

On the pattern pages these problems carry a Apple badge. Frequency is LeetCode's relative score for this list (100 = asked most often). Read a pattern page first, then work through its group here from the most to the least frequent problem.

A 6-month plan

About 5–6 problems on 5 days a week. Each month: read the pattern page, solve its worked examples without looking, then this list. Re-solve anything you needed a hint for one week later.

WhenFocusPatterns (problems on the list)Total
Month 1Foundations: arrays you can scan01 · Prefix Sum (1)
02 · Two Pointers (6)
03 · Sliding Window (4)
05 · LinkedList In-place Reversal (2)
21 · Array & String Basics (3)
16
Month 2Stacks, heaps, intervals, binary search07 · Top 'K' Elements (4)
08 · Overlapping Intervals (2)
09 · Modified Binary Search (4)
17 · Stack (4)
14
Month 3Trees and graphs10 · Binary Tree Traversal (3)
11 · Depth-First Search (DFS) on Graphs (5)
12 · Breadth-First Search (BFS) (3)
13 · Matrix Traversal (4)
15
Month 4Search and dynamic programming14 · Backtracking (1)
15 · Dynamic Programming Patterns (5)
6
Month 5Hashing, greedy, design, weighted graphs16 · Hash Map & Set (5)
18 · Greedy (2)
19 · Trie & Design (7)
20 · Shortest Path & MST (1)
15
Month 6Math, range structures, then mock interviews22 · Math & Bit Manipulation (2)2

In the last two weeks, filter to Hard, sort your attention by frequency, and do timed mock interviews: 45 minutes, talk through the brute force, name the pattern, then code it.

All problems

01 02 03 05 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 SQL/JS

01 · Prefix Sum 1

1 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
560Subarray Sum Equals KMedium75Array, Hash Table, Prefix Sum

02 · Two Pointers 6

5 solved on the pattern page (step-by-step explanation and a step-through player), 1 Easy warm-ups that link to LeetCode.

Done#ProblemLevelFrequencyTopicsLinks
153SumMedium70Array, Two Pointers, Sorting
125Valid PalindromeEasy65Two Pointers, String
189Rotate ArrayMedium48Array, Math, Two Pointers
5Longest Palindromic SubstringMedium48Two Pointers, String, Dynamic Programming, Manacher
4Median of Two Sorted ArraysHard48Array, Binary Search, Divide and Conquer
283Move ZeroesEasy48Array, Two Pointers

03 · Sliding Window 4

4 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
121Best Time to Buy and Sell StockEasy78Array, Dynamic Programming
713Subarray Product Less Than KMedium75Array, Binary Search, Sliding Window, Prefix Sum
3Longest Substring Without Repeating CharactersMedium65Hash Table, String, Sliding Window
567Permutation in StringMedium48Hash Table, Two Pointers, String, Sliding Window

05 · LinkedList In-place Reversal 2

2 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
206Reverse Linked ListEasy78Linked List, Recursion
328Odd Even Linked ListMedium48Linked List

07 · Top 'K' Elements 4

4 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
621Task SchedulerMedium65Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Counting
23Merge k Sorted ListsHard58Linked List, Divide and Conquer, Heap (Priority Queue), Merge Sort, Tournament Sort
347Top K Frequent ElementsMedium48Array, Hash Table, Divide and Conquer, Sorting, Heap (Priority Queue), Bucket Sort, Counting, Quickselect
295Find Median from Data StreamHard48Two Pointers, Design, Sorting, Heap (Priority Queue), Data Stream

08 · Overlapping Intervals 2

2 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
56Merge IntervalsMedium95Array, Sorting, Quicksort
252Meeting Rooms PremiumEasy58Array, Sorting, Quicksort

09 · Modified Binary Search 4

4 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
981Time Based Key-Value StoreMedium75Hash Table, String, Binary Search, Design
34Find First and Last Position of Element in Sorted ArrayMedium70Array, Binary Search
1146Snapshot ArrayMedium58Array, Hash Table, Binary Search, Design, Persistent Data Structure
33Search in Rotated Sorted ArrayMedium48Array, Binary Search

10 · Binary Tree Traversal 3

3 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
428Serialize and Deserialize N-ary Tree PremiumHard65String, Tree, Depth-First Search, Breadth-First Search
314Binary Tree Vertical Order Traversal PremiumMedium48Hash Table, Tree, Depth-First Search, Breadth-First Search, Sorting, Binary Tree
889Construct Binary Tree from Preorder and Postorder TraversalMedium48Array, Hash Table, Divide and Conquer, Tree, Binary Tree

11 · Depth-First Search (DFS) on Graphs 5

5 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
210Course Schedule IIMedium87Depth-First Search, Breadth-First Search, Graph Theory, Topological Sort
207Course ScheduleMedium58Depth-First Search, Breadth-First Search, Graph Theory, Topological Sort, Directed Acyclic Graph
785Is Graph Bipartite?Medium58Depth-First Search, Breadth-First Search, Union-Find, Graph Theory, Graph Coloring, Bipartite Graph
841Keys and RoomsMedium48Depth-First Search, Breadth-First Search, Graph Theory
332Reconstruct ItineraryHard48Array, String, Depth-First Search, Graph Theory, Sorting, Heap (Priority Queue), Eulerian Circuit, Eulerian Path, Semi-Eulerian Graph

12 · Breadth-First Search (BFS) 3

3 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
127Word LadderHard58Hash Table, String, Breadth-First Search, Bidirectional Search
1197Minimum Knight Moves PremiumMedium48Breadth-First Search, Heuristic Search, Bidirectional Search, A* Search
863All Nodes Distance K in Binary TreeMedium48Hash Table, Tree, Depth-First Search, Breadth-First Search, Binary Tree

13 · Matrix Traversal 4

4 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
200Number of IslandsMedium82Array, Depth-First Search, Breadth-First Search, Union-Find, Matrix
54Spiral MatrixMedium65Array, Matrix, Simulation
48Rotate ImageMedium65Array, Math, Matrix
59Spiral Matrix IIMedium48Array, Matrix, Simulation

14 · Backtracking 1

1 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
17Letter Combinations of a Phone NumberMedium48Hash Table, String, Backtracking

15 · Dynamic Programming Patterns 5

5 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
72Edit DistanceMedium65String, Dynamic Programming
309Best Time to Buy and Sell Stock with CooldownMedium58Array, Dynamic Programming
714Best Time to Buy and Sell Stock with Transaction FeeMedium48Array, Dynamic Programming, Greedy
416Partition Equal Subset SumMedium48Array, Dynamic Programming, Knapsack Problem, 0-1 Knapsack
688Knight Probability in ChessboardMedium48Dynamic Programming

16 · Hash Map & Set 5

5 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
49Group AnagramsMedium84Array, Hash Table, String, Sorting
1Two SumEasy75Array, Hash Table
2150Find All Lonely Numbers in the ArrayMedium65Array, Hash Table, Counting
36Valid SudokuMedium48Array, Hash Table, Matrix
128Longest Consecutive SequenceMedium48Array, Hash Table, Union-Find

17 · Stack 4

4 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
362Design Hit Counter PremiumMedium92Array, Binary Search, Design, Queue, Data Stream
227Basic Calculator IIMedium75Math, String, Stack
736Parse Lisp ExpressionHard48Hash Table, String, Stack, Recursion
678Valid Parenthesis StringMedium48String, Dynamic Programming, Stack, Greedy, Bracket Sequences

18 · Greedy 2

2 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
122Best Time to Buy and Sell Stock IIMedium65Array, Dynamic Programming, Greedy
670Maximum SwapMedium58Math, Greedy

19 · Trie & Design 7

7 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
146LRU CacheMedium100Hash Table, Linked List, Design, Doubly-Linked List
380Insert Delete GetRandom O(1)Medium82Array, Hash Table, Math, Design, Randomized
2502Design Memory AllocatorMedium65Array, Hash Table, Design, Simulation
3408Design Task ManagerMedium58Hash Table, Design, Heap (Priority Queue), Ordered Set
208Implement Trie (Prefix Tree)Medium48Hash Table, String, Design, Trie
635Design Log Storage System PremiumMedium48Hash Table, String, Design, Ordered Set
460LFU CacheHard48Hash Table, Linked List, Design, Doubly-Linked List

20 · Shortest Path & MST 1

1 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
787Cheapest Flights Within K StopsMedium48Dynamic Programming, Depth-First Search, Breadth-First Search, Graph Theory, Heap (Priority Queue), Shortest Path

21 · Array & String Basics 3

3 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
14Longest Common PrefixEasy75Array, String, Trie
151Reverse Words in a StringMedium48Two Pointers, String
68Text JustificationHard48Array, String, Simulation

22 · Math & Bit Manipulation 2

2 solved on the pattern page (step-by-step explanation and a step-through player).

Done#ProblemLevelFrequencyTopicsLinks
477Total Hamming DistanceMedium65Array, Math, Bit Manipulation
7Reverse IntegerMedium58Math

SQL & JavaScript (practice on LeetCode) 1

Database and JavaScript problems from the list. They aren't Python algorithm problems, so they link straight to LeetCode.

Done#ProblemLevelFrequencyTopicsLinks
2633Convert Object to JSON String PremiumMedium48