~/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 75
The essentials: one pass through every interview topic, the problems that come up again and again.
0 of 75 solved
75 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
- Valid Palindrome 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
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
- Best Time to Buy and Sell Stock py · c++ · java easy
Binary search Sorted lookups, rotations, searching the answer.
Binary search guide
- Search in Rotated Sorted Array py · c++ · java medium
- Find Minimum in Rotated Sorted Array 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
Trees Traversals, BSTs, and answers built bottom-up.
Binary trees guide
- Binary Tree Level Order Traversal py · c++ · java easy
- Validate Binary Search Tree py · c++ · java medium
- Serialize and Deserialize Binary Tree medium
- Maximum Depth of Binary Tree py · c++ · java easy
- Invert 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
- 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
Heaps Top-k, merging streams, scheduling by time.
Heaps and priority queues guide
- Top K Frequent Elements py · c++ · java easy
- Merge K Sorted Lists py · c++ · java medium
- Find Median from Data Stream py · c++ · java medium
Backtracking Recursion that tries, undoes and tries again.
- Word Search 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.
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
Topological sort (Kahn's) guide
- Course Schedule 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
- House Robber II py · c++ · java medium
- Maximum Product Subarray py · c++ · java medium
Longest increasing subsequence guide
- Longest Increasing Subsequence py · c++ · java medium
Weighted graphs Dijkstra, union-find, spanning trees.
Union-Find guide
- Graph Valid Tree py · c++ · java medium
2-D dynamic programming Grids, two strings, knapsacks, ranges.
Grid DP guide
- Minimum Path Sum py · c++ · java easy
String DP (edit distance, LCS) guide
- Longest Common Subsequence py · c++ · java medium
- Longest Palindromic Substring py · c++ · java medium
- Palindromic Substrings py · c++ · java medium
Knapsack and coin change guide
- Coin Change 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