~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Algos 150
Algos 75 plus the next tier of classics, company-style assessments, and the practical, concurrency and quant staples.
0 of 150 solved
150 problems
Interview roadmap
Arrays & hashing Counting, lookups, sorting with keys, prefix sums.
Hash maps and counting guide
- Two Sum py · c++ · java easy
- Contains Duplicate py · c++ · java easy
- Valid Anagram py · c++ · java easy
- Group Anagrams py · c++ · java easy
- Longest Consecutive Sequence py · c++ · java medium
- Encode and Decode Strings medium
Prefix sums and difference arrays guide
- Product of Array Except Self py · c++ · java medium
Two pointers Scan from both ends, or fast and slow.
- 3Sum py · c++ · java medium
- Container with Most Water py · c++ · java medium
- Remove Duplicates from Sorted Array easy
- Valid Palindrome py · c++ · java easy
- Two Sum II (Sorted Input) py · c++ · java easy
Stacks Matching brackets, paths, next greater element.
Stacks guide
- Valid Parentheses py · c++ · java easy
- Min Stack py · c++ · java medium
- Evaluate Reverse Polish Notation py · c++ · java medium
Monotonic stack guide
- Daily Temperatures py · c++ · java easy
- Largest Rectangle in Histogram py · c++ · java hard
- Trapping Rain Water py · c++ · java medium
- Car Fleet py · c++ · java medium
Math & matrices Digit arithmetic, rotating and marking grids in place.
- Rotate Image py · c++ · java medium
- Set Matrix Zeroes py · c++ · java medium
Sliding window Grow and shrink a window over a string or array.
- Longest Substring Without Repeating Characters py · c++ · java medium
- Longest Repeating Character Replacement py · c++ · java medium
- Minimum Window Substring py · c++ · java hard
- Sliding Window Maximum py · c++ · java hard
- Best Time to Buy and Sell Stock py · c++ · java easy
- Permutation in String py · c++ · java medium
Binary search Sorted lookups, rotations, searching the answer.
Binary search guide
- Binary Search py · c++ · java easy
- Find First and Last Position of Element in Sorted Array py · c++ · java medium
- Search in Rotated Sorted Array py · c++ · java medium
- Find Minimum in Rotated Sorted Array py · c++ · java medium
- Search a 2D Matrix py · c++ · java medium
- Median of Two Sorted Arrays py · c++ · java hard
Binary search on the answer guide
- Koko Eating Bananas py · c++ · java medium
Sorted containers (bisect) guide
- OA: Game leaderboard 3 levels py · c++ · java medium
- OA: Spreading keys over a ring of servers 3 levels py · c++ · java medium
Linked lists Reverse, merge, detect cycles, build an LRU cache.
Linked lists guide
- Reverse Linked List py · c++ · java easy
- Merge Two Sorted Lists py · c++ · java easy
- Remove Nth Node from End of List py · c++ · java easy
- Where does the cycle start? medium
- Reorder List py · c++ · java medium
- Copy List with Random Pointer medium
- Add Two Numbers py · c++ · java medium
- Find the Duplicate Number py · c++ · java medium
- Reverse Nodes in k-Group py · c++ · java hard
Trees Traversals, BSTs, and answers built bottom-up.
Binary trees guide
- Diameter of Binary Tree py · c++ · java easy
- Binary Tree Level Order Traversal py · c++ · java easy
- Validate Binary Search Tree py · c++ · java medium
- Lowest Common Ancestor of a Binary Tree medium
- Serialize and Deserialize Binary Tree medium
- Maximum Depth of Binary Tree py · c++ · java easy
- Invert Binary Tree py · c++ · java easy
- Balanced Binary Tree py · c++ · java easy
- Same Tree py · c++ · java easy
- Subtree of Another Tree py · c++ · java easy
- Lowest Common Ancestor of a Binary Search Tree py · c++ · java medium
- Binary Tree Right Side View py · c++ · java medium
- Count Good Nodes in Binary Tree py · c++ · java medium
- Kth Smallest Element in a BST py · c++ · java medium
- Construct Binary Tree from Preorder and Inorder Traversal py · c++ · java medium
Tree DP guide
- Binary Tree Maximum Path Sum py · c++ · java medium
Tries Prefix trees for words and autocomplete.
- Implement Trie (Prefix Tree) py · c++ · java easy
- Design Add and Search Words Data Structure py · c++ · java medium
- Word Search II py · c++ · java hard
- OA: Search box suggestions 3 levels py · c++ · java medium
Heaps Top-k, merging streams, scheduling by time.
Heaps and priority queues guide
- Top K Frequent Elements py · c++ · java easy
- Kth Largest Element in an Array py · c++ · java medium
- Merge K Sorted Lists py · c++ · java medium
- Find Median from Data Stream py · c++ · java medium
- Kth Largest Element in a Stream py · c++ · java easy
- Last Stone Weight py · c++ · java easy
- Design Twitter py · c++ · java medium
Heap scheduling (deadlines, leases) guide
- Task Scheduler py · c++ · java medium
Backtracking Recursion that tries, undoes and tries again.
- Subsets py · c++ · java easy
- Permutations py · c++ · java easy
- Combination Sum py · c++ · java medium
- N-Queens py · c++ · java medium
- Combination Sum II py · c++ · java medium
- Subsets II py · c++ · java medium
- Word Search py · c++ · java medium
- Palindrome Partitioning py · c++ · java medium
- Letter Combinations of a Phone Number py · c++ · java medium
Intervals Merge, insert and sweep over ranges.
- Merge Intervals Roblox py · c++ · java easy
- Insert Interval py · c++ · java medium
- Meeting Rooms II py · c++ · java medium
Greedy Sort, then take the locally best choice.
- Non-overlapping Intervals py · c++ · java medium
- Jump Game py · c++ · java easy
Graphs Grids and networks: BFS, DFS, cycles, ordering.
BFS / multi-source BFS guide
- Rotting Oranges py · c++ · java medium
- Walls and Gates py · c++ · java medium
- Word Ladder py · c++ · java hard
DFS and connected components guide
- Number of Islands py · c++ · java easy
- Clone Graph medium
- Pacific Atlantic Water Flow py · c++ · java medium
- Number of Connected Components in an Undirected Graph py · c++ · java easy
- Surrounded Regions py · c++ · java medium
- Chain every word end to start py · c++ · java hard
Topological sort (Kahn's) guide
- Course Schedule py · c++ · java easy
- Course Schedule II py · c++ · java easy
- Alien Dictionary py · c++ · java medium
1-D dynamic programming One index of state: stairs, robbers, subsequences.
Intro DP guide
- Climbing Stairs py · c++ · java easy
- House Robber py · c++ · java easy
- Decode Ways medium
- Maximum Subarray py · c++ · java easy
- Word Break py · c++ · java medium
- Cheapest climb with strides of one to three steps py · c++ · java easy
- House Robber II py · c++ · java medium
- Maximum Product Subarray py · c++ · java medium
- Best Time to Buy and Sell Stock with Cooldown py · c++ · java medium
Longest increasing subsequence guide
- Longest Increasing Subsequence py · c++ · java medium
Weighted graphs Dijkstra, union-find, spanning trees.
Dijkstra (weighted shortest paths) guide
- Network Delay Time py · c++ · java easy
- Swim in Rising Water py · c++ · java hard
Union-Find guide
- Redundant Connection py · c++ · java medium
- Graph Valid Tree py · c++ · java medium
Minimum spanning tree guide
- Min Cost to Connect All Points py · c++ · java medium
2-D dynamic programming Grids, two strings, knapsacks, ranges.
Grid DP guide
- Minimum Path Sum py · c++ · java easy
- Longest Increasing Path in a Matrix py · c++ · java hard
String DP (edit distance, LCS) guide
- Edit Distance py · c++ · java medium
- Longest Common Subsequence py · c++ · java medium
- Longest Palindromic Substring py · c++ · java medium
- Palindromic Substrings py · c++ · java medium
- Interleaving String py · c++ · java medium
- Distinct Subsequences py · c++ · java hard
Knapsack and coin change guide
- Coin Change py · c++ · java medium
- Coin Change II py · c++ · java medium
- Partition Equal Subset Sum py · c++ · java medium
- Combination Sum IV py · c++ · java medium
Bit manipulation Masks, shifts and IP-address arithmetic.
- Number of 1 Bits py · c++ · java easy
- Counting Bits py · c++ · java easy
- Reverse Bits py · c++ · java easy
- Missing Number py · c++ · java easy
- Sum of Two Integers py · c++ · java medium
Practical systems
Simulation & OOP design Model the rules precisely, keep it extensible.
Simulation
- Spiral Matrix py · c++ · java easy
Object-oriented design and extensible simulations
- OA: Text editor with a clipboard, undo and several documents 4 levels py · c++ · java hard
- OA: File finder with saved, combinable search rules 4 levels py · c++ · java medium
- OA: Parking garage with fees and reservations 3 levels py · c++ · java medium
- OA: Shop inventory with timed holds and backorders 4 levels py · c++ · java hard
Stateful stores Key-value stores, file systems, banks, with history.
Time-travel key-value store
- Time-Based Key-Value Store Citadel py · c++ · java easy
In-memory file system
- OA: Cloud file storage 4 levels Anthropic py · c++ · java medium
In-memory database
- OA: In-memory database 5 levels Anthropic medium
Bank system
- OA: Bank system 4 levels Anthropic py · c++ · java medium
Iterators & parsers Lazy sequences, tokenizers and tiny interpreters.
Parsers and interpreters
- OA: Subword tokenizer: train, encode, decode 3 levels py · c++ · java medium
Streams & durability Rate counters, serialization, retrying work queues.
Rolling windows and rate counters
- OA: Throttle requests per client 4 levels py · c++ · java hard
Fault-tolerant work queue
- OA: Fault-tolerant work queue 3 levels OpenAI medium
Concurrency
Coordination Semaphores, conditions and barriers.
Semaphore
- Bounded blocking queue medium
Pools & pipelines Thread pools, crawlers, producer/consumer buffers.
Thread pool / concurrent crawler
- Concurrent web crawler 3 levels Anthropic medium
Quant & trading
Probability Expected value, sampling, randomized algorithms.
Probability and expected value
Trading systems Order books, matching engines, market simulations.
Order books and matching engines
- One-share order book matching Optiver py · c++ · java medium