Problem bank
Every problem from every pattern ladder in one place. Filter by pattern or difficulty, and tick off what you've solved — it syncs with the pattern pages.
Easy
0/31
Medium
0/90
Hard
0/21
Total
0/142
| Done | Problem | Pattern | Level | Companies |
|---|---|---|---|---|
| Valid Palindrome ↗ Compare characters from both ends, skipping non-alphanumerics. | Two Pointers | Easy | Meta, Microsoft, Amazon | |
| Move Zeroes ↗ One pointer reads, another marks where the next non-zero goes. | Two Pointers | Easy | Meta, Amazon, Apple | |
| Squares of a Sorted Array ↗ The biggest square is always at one of the two ends. | Two Pointers | Easy | Amazon, Google | |
| Two Sum II - Input Array Is Sorted ↗ Sum too big? Only one pointer can fix that. | Two Pointers | Medium | Amazon, Google, Meta | |
| 3Sum ↗ Fix one number, then it's Two Sum II on the rest. | Two Pointers | Medium | Meta, Amazon, Google, Microsoft | |
| Container With Most Water ↗ The shorter wall limits the area — which one is worth moving? | Two Pointers | Medium | Amazon, Google, Meta | |
| Sort Colors ↗ Three regions, three pointers, one pass. | Two Pointers | Medium | Microsoft, Amazon | |
| Trapping Rain Water ↗ Water at a spot depends on the smaller of the tallest walls on each side. | Two Pointers | Hard | Amazon, Google, Goldman Sachs, Meta | |
| Maximum Average Subarray I ↗ Fixed width: add the new element, drop the old one. | Sliding Window | Easy | Google, Amazon | |
| Longest Substring Without Repeating Characters ↗ When a repeat enters, pull the left edge past it. | Sliding Window | Medium | Amazon, Google, Meta, Microsoft | |
| Minimum Size Subarray Sum ↗ All positives — once the sum is big enough, shrink. | Sliding Window | Medium | Meta, Amazon | |
| Fruit Into Baskets ↗ Longest window with at most two distinct values. | Sliding Window | Medium | Google, Amazon | |
| Longest Repeating Character Replacement ↗ Window is valid while length minus its most common char ≤ k. | Sliding Window | Medium | Google, Amazon, Uber | |
| Permutation in String ↗ Fixed window of len(s1); compare letter counts. | Sliding Window | Medium | Microsoft, Meta | |
| Minimum Window Substring ↗ Expand until every needed char is covered, then shrink greedily. | Sliding Window | Hard | Meta, Amazon, Google, LinkedIn | |
| Sliding Window Maximum ↗ Keep only indices that could still become the max. | Sliding Window | Hard | Amazon, Google, Microsoft | |
| Find Pivot Index ↗ Left sum vs total minus left minus current. | Prefix Sum + Hash Map | Easy | Amazon, Meta | |
| Range Sum Query - Immutable ↗ Precompute once, answer each query by subtraction. | Prefix Sum + Hash Map | Easy | Meta, Amazon | |
| Subarray Sum Equals K ↗ Which earlier running total would make this one work? | Prefix Sum + Hash Map | Medium | Meta, Amazon, Google, Microsoft | |
| Contiguous Array ↗ Treat 0 as -1; you're now looking for sum 0. | Prefix Sum + Hash Map | Medium | Meta, Amazon | |
| Continuous Subarray Sum ↗ Same remainder twice, at least two apart. | Prefix Sum + Hash Map | Medium | Meta, Amazon | |
| Subarray Sums Divisible by K ↗ Count prefix remainders, not prefix sums. | Prefix Sum + Hash Map | Medium | Meta, Amazon | |
| Count Number of Nice Subarrays ↗ Map each number to 1 if odd, 0 if even — familiar now? | Prefix Sum + Hash Map | Medium | Google, Amazon | |
| Number of Submatrices That Sum to Target ↗ Fix a pair of rows, collapse columns, reuse the 1-D trick. | Prefix Sum + Hash Map | Hard | Google, Meta | |
| Binary Search ↗ Compare to the middle, discard half. | Binary Search | Easy | Google, Microsoft | |
| Search Insert Position ↗ First index whose value is ≥ target. | Binary Search | Easy | Amazon, Apple | |
| First Bad Version ↗ Good…good, bad…bad — find the first bad. | Binary Search | Easy | Meta, Microsoft | |
| Find First and Last Position of Element in Sorted Array ↗ Two lower-bound searches: for target and target + 1. | Binary Search | Medium | Meta, Amazon, LinkedIn | |
| Search in Rotated Sorted Array ↗ One side of mid is always sorted. | Binary Search | Medium | Meta, Amazon, Microsoft, LinkedIn | |
| Koko Eating Bananas ↗ Search over speeds; can she finish in time? | Binary Search | Medium | Google, Amazon, Airbnb | |
| Capacity To Ship Packages Within D Days ↗ Guess a capacity, simulate the days. | Binary Search | Medium | Amazon, Google | |
| Median of Two Sorted Arrays ↗ Binary search the cut position in the smaller array. | Binary Search | Hard | Google, Amazon, Goldman Sachs, Apple | |
| Next Greater Element I ↗ Precompute next-greater for nums2 once. | Monotonic Stack | Easy | Amazon, Bloomberg | |
| Daily Temperatures ↗ Who's still waiting for a warmer day? | Monotonic Stack | Medium | Amazon, Meta, Google | |
| Online Stock Span ↗ Collapse smaller previous prices into the current one. | Monotonic Stack | Medium | Amazon, Microsoft | |
| Next Greater Element II ↗ Walk the array twice. | Monotonic Stack | Medium | Amazon, Google | |
| Remove K Digits ↗ A bigger digit before a smaller one should go. | Monotonic Stack | Medium | Amazon, Microsoft | |
| Sum of Subarray Minimums ↗ For each element: how far left and right is it the minimum? | Monotonic Stack | Medium | Amazon, Google | |
| Largest Rectangle in Histogram ↗ A bar's rectangle ends at the first shorter bar on each side. | Monotonic Stack | Hard | Amazon, Google, Microsoft | |
| Maximal Rectangle ↗ Each row is the base of a histogram. | Monotonic Stack | Hard | Google, Meta | |
| Summary Ranges ↗ Build ranges while the next number continues the run. | Merge Intervals | Easy | Google, Meta | |
| Merge Intervals ↗ After sorting, who can the next interval possibly overlap? | Merge Intervals | Medium | Meta, Google, Amazon, Microsoft | |
| Insert Interval ↗ Three phases: before, overlapping, after. | Merge Intervals | Medium | Google, LinkedIn, Meta | |
| Non-overlapping Intervals ↗ Keep the one that ends first. | Merge Intervals | Medium | Meta, Amazon | |
| Minimum Number of Arrows to Burst Balloons ↗ Shoot at the earliest end point. | Merge Intervals | Medium | Amazon, Microsoft | |
| Interval List Intersections ↗ Two pointers; advance whoever finishes first. | Merge Intervals | Medium | Meta, Uber | |
| Car Pooling ↗ Passengers on at start, off at end — track the peak. | Merge Intervals | Medium | Google, Lyft | |
| Data Stream as Disjoint Intervals ↗ Keep intervals sorted; a new number can join neighbours. | Merge Intervals | Hard | Google, Amazon | |
| Assign Cookies ↗ Smallest cookie that satisfies the least greedy child. | Greedy | Easy | Amazon | |
| Best Time to Buy and Sell Stock II ↗ Collect every upward step. | Greedy | Medium | Amazon, Bloomberg, Meta | |
| Jump Game ↗ Track how far you could get. | Greedy | Medium | Amazon, Meta, Microsoft | |
| Jump Game II ↗ Think of reachable ranges as BFS levels. | Greedy | Medium | Amazon, Google | |
| Gas Station ↗ If you run dry at i, every start before i fails too. | Greedy | Medium | Amazon, Google, Bloomberg | |
| Partition Labels ↗ A part can't end before the last occurrence of any letter in it. | Greedy | Medium | Amazon, Meta | |
| Hand of Straights ↗ The smallest card must start a group. | Greedy | Medium | ||
| Candy ↗ Two passes: left neighbours, then right neighbours. | Greedy | Hard | Amazon, Microsoft | |
| Linked List Cycle ↗ Will a faster runner ever catch a slower one? | Fast & Slow Pointers | Easy | Amazon, Microsoft, Bloomberg | |
| Middle of the Linked List ↗ Half speed lands halfway. | Fast & Slow Pointers | Easy | Amazon, Apple | |
| Happy Number ↗ The digit-square process is a hidden linked list. | Fast & Slow Pointers | Easy | Google, Apple | |
| Palindrome Linked List ↗ Find the middle, then compare halves. | Fast & Slow Pointers | Easy | Meta, Amazon, Microsoft | |
| Linked List Cycle II ↗ After meeting, restart one pointer from head. | Fast & Slow Pointers | Medium | Amazon, Microsoft | |
| Remove Nth Node From End of List ↗ Give one pointer an n-step head start. | Fast & Slow Pointers | Medium | Meta, Amazon, Google | |
| Reorder List ↗ Middle, reverse second half, weave. | Fast & Slow Pointers | Medium | Meta, Amazon | |
| Find the Duplicate Number ↗ Indices as nodes, values as next pointers. | Fast & Slow Pointers | Medium | Google, Amazon, Microsoft | |
| Reverse Linked List ↗ Three references are all you need. | In-place Reversal | Easy | Amazon, Microsoft, Apple, Meta | |
| Reverse Linked List II ↗ Anchor the node just before the segment. | In-place Reversal | Medium | Meta, Amazon, Microsoft | |
| Swap Nodes in Pairs ↗ It's reversal with k = 2. | In-place Reversal | Medium | Amazon, Microsoft | |
| Rotate List ↗ Close it into a ring, then cut at the right spot. | In-place Reversal | Medium | Amazon, LinkedIn | |
| Maximum Twin Sum of a Linked List ↗ Reverse the second half and walk both halves together. | In-place Reversal | Medium | Amazon | |
| Reverse Nodes in k-Group ↗ Count k ahead before you flip anything. | In-place Reversal | Hard | Amazon, Microsoft, Meta, Google | |
| Kth Largest Element in a Stream ↗ Keep only k seats on stage. | Heap / Top-K | Easy | Amazon, Meta | |
| Last Stone Weight ↗ Always grab the two heaviest. | Heap / Top-K | Easy | Amazon, Google | |
| Kth Largest Element in an Array ↗ You don't need the whole array sorted. | Heap / Top-K | Medium | Meta, Amazon, Microsoft, LinkedIn | |
| Top K Frequent Elements ↗ Count first, then keep the best k counts. | Heap / Top-K | Medium | Amazon, Meta, Google | |
| K Closest Points to Origin ↗ Keep the k smallest distances — which heap evicts the farthest? | Heap / Top-K | Medium | Meta, Amazon, LinkedIn | |
| Task Scheduler ↗ Always run the most frequent available task. | Heap / Top-K | Medium | Meta, Amazon, Microsoft | |
| Merge k Sorted Lists ↗ The next output node is the smallest of k heads. | Heap / Top-K | Hard | Amazon, Meta, Google, Microsoft | |
| Find Median from Data Stream ↗ Two heaps facing each other. | Heap / Top-K | Hard | Amazon, Google, Microsoft | |
| Minimum Depth of Binary Tree ↗ The first leaf you meet floor by floor wins. | Tree BFS (Level Order) | Easy | Amazon, Meta | |
| Average of Levels in Binary Tree ↗ Sum and count per level. | Tree BFS (Level Order) | Easy | Meta, Amazon | |
| Binary Tree Level Order Traversal ↗ Freeze the queue length at the start of each floor. | Tree BFS (Level Order) | Medium | Amazon, Meta, Microsoft, LinkedIn | |
| Binary Tree Right Side View ↗ Who's last on each floor? | Tree BFS (Level Order) | Medium | Meta, Amazon, Bloomberg | |
| Binary Tree Zigzag Level Order Traversal ↗ Same BFS, flip direction each level. | Tree BFS (Level Order) | Medium | Amazon, Microsoft, Bloomberg | |
| Populating Next Right Pointers in Each Node ↗ Neighbours on the same floor are adjacent in the queue. | Tree BFS (Level Order) | Medium | Microsoft, Amazon | |
| Maximum Width of Binary Tree ↗ Number positions like a heap: 2i and 2i+1. | Tree BFS (Level Order) | Medium | Amazon, Google | |
| Serialize and Deserialize Binary Tree ↗ Level order with explicit null markers. | Tree BFS (Level Order) | Hard | Amazon, Meta, Google, LinkedIn | |
| Maximum Depth of Binary Tree ↗ Ask both children, take the bigger, add one. | Tree DFS (Recursion) | Easy | Amazon, LinkedIn, Microsoft | |
| Invert Binary Tree ↗ Swap, then let recursion handle the rest. | Tree DFS (Recursion) | Easy | Google, Amazon | |
| Diameter of Binary Tree ↗ Return height, but record left + right. | Tree DFS (Recursion) | Easy | Meta, Amazon, Google | |
| Balanced Binary Tree ↗ Compute height and balance in the same pass. | Tree DFS (Recursion) | Easy | Amazon, Bloomberg | |
| Validate Binary Search Tree ↗ Every node lives inside a range set by its ancestors. | Tree DFS (Recursion) | Medium | Amazon, Meta, Microsoft, Bloomberg | |
| Lowest Common Ancestor of a Binary Tree ↗ If both sides report a hit, you're the answer. | Tree DFS (Recursion) | Medium | Meta, Amazon, Microsoft, LinkedIn | |
| Path Sum II ↗ Carry the remaining target down; undo on the way back. | Tree DFS (Recursion) | Medium | Amazon, Meta | |
| Binary Tree Maximum Path Sum ↗ Return the best single arm; record the best bend. | Tree DFS (Recursion) | Hard | Meta, Amazon, Google, Microsoft | |
| Flood Fill ↗ Spread from one cell to same-coloured neighbours. | Graph BFS / DFS (Grids) | Easy | Amazon, Microsoft | |
| Number of Islands ↗ Each new paint bucket is one island. | Graph BFS / DFS (Grids) | Medium | Amazon, Meta, Google, Microsoft | |
| Max Area of Island ↗ Count cells while you flood. | Graph BFS / DFS (Grids) | Medium | Amazon, Google | |
| Rotting Oranges ↗ All rotten oranges spread at the same time. | Graph BFS / DFS (Grids) | Medium | Amazon, Microsoft, Google | |
| Surrounded Regions ↗ What's safe is connected to the border. | Graph BFS / DFS (Grids) | Medium | Google, Amazon | |
| Pacific Atlantic Water Flow ↗ Let water flow uphill from each ocean. | Graph BFS / DFS (Grids) | Medium | Google, Amazon | |
| Clone Graph ↗ Map old node → new node as you traverse. | Graph BFS / DFS (Grids) | Medium | Meta, Google, Amazon | |
| Word Ladder ↗ Words are nodes; one-letter changes are edges; shortest path. | Graph BFS / DFS (Grids) | Hard | Amazon, Meta, Google, LinkedIn | |
| Course Schedule ↗ Can every course's blockers eventually clear? | Topological Sort | Medium | Amazon, Meta, Google, Microsoft | |
| Course Schedule II ↗ Record the order in which blockers clear. | Topological Sort | Medium | Amazon, Meta, Google | |
| Find All Possible Recipes from Given Supplies ↗ Ingredients are prerequisites of recipes. | Topological Sort | Medium | Google, Amazon | |
| Find Eventual Safe States ↗ Reverse the edges and peel off nodes with no outgoing paths. | Topological Sort | Medium | Google, Amazon | |
| Course Schedule IV ↗ Propagate prerequisite sets in topological order. | Topological Sort | Medium | Google, Amazon | |
| Minimum Height Trees ↗ Peel leaves layer by layer toward the centre. | Topological Sort | Medium | Google, Amazon | |
| Parallel Courses III ↗ Earliest finish = own time + latest-finishing prerequisite. | Topological Sort | Hard | Google, Amazon | |
| Sort Items by Groups Respecting Dependencies ↗ Two levels of topological sort: groups, then items. | Topological Sort | Hard | ||
| Find if Path Exists in Graph ↗ Same leader means same group. | Union-Find (DSU) | Easy | Amazon, Google | |
| Number of Provinces ↗ Start with n groups; each real merge removes one. | Union-Find (DSU) | Medium | Amazon, Meta, Google | |
| Redundant Connection ↗ Which edge joins two already-joined nodes? | Union-Find (DSU) | Medium | Google, Amazon | |
| Number of Operations to Make Network Connected ↗ Spare cables vs components minus one. | Union-Find (DSU) | Medium | Amazon, Microsoft | |
| Satisfiability of Equality Equations ↗ Union all '==' first, then check every '!='. | Union-Find (DSU) | Medium | ||
| Accounts Merge ↗ Emails are nodes; an account unions its emails. | Union-Find (DSU) | Medium | Meta, Google, Amazon | |
| Most Stones Removed with Same Row or Column ↗ Answer = stones minus number of groups. | Union-Find (DSU) | Medium | Google, Amazon | |
| Swim in Rising Water ↗ Add cells by height until corners connect. | Union-Find (DSU) | Hard | Google, Amazon | |
| Binary Tree Paths ↗ Extend the path going down, trim it coming back. | Backtracking | Easy | Google, Meta | |
| Subsets ↗ Each element: in or out. | Backtracking | Medium | Meta, Amazon, Google | |
| Permutations ↗ Any unused element can go in the next slot. | Backtracking | Medium | Microsoft, Amazon, LinkedIn | |
| Combination Sum ↗ You may pick the same number again — where does the next call start? | Backtracking | Medium | Airbnb, Amazon, Uber | |
| Subsets II ↗ Sort, then skip equal siblings. | Backtracking | Medium | Amazon, Meta | |
| Letter Combinations of a Phone Number ↗ One digit per level of the tree. | Backtracking | Medium | Amazon, Meta, Uber | |
| Word Search ↗ Mark a cell while it's on the path, unmark on the way back. | Backtracking | Medium | Amazon, Microsoft, Meta | |
| N-Queens ↗ One queen per row; track used columns and diagonals. | Backtracking | Hard | Amazon, Google, Microsoft | |
| Climbing Stairs ↗ How could you have arrived at the last step? | 1-D Dynamic Programming | Easy | Amazon, Google, Adobe | |
| Min Cost Climbing Stairs ↗ Cheapest way to stand on step i. | 1-D Dynamic Programming | Easy | Amazon | |
| House Robber ↗ Rob this one plus two back, or skip it. | 1-D Dynamic Programming | Medium | Amazon, Google, Cisco | |
| House Robber II ↗ Break the circle two different ways. | 1-D Dynamic Programming | Medium | Amazon, Microsoft | |
| Decode Ways ↗ Last char alone, or last two together? | 1-D Dynamic Programming | Medium | Meta, Google, Amazon | |
| Coin Change ↗ Which coin did you use last? | 1-D Dynamic Programming | Medium | Amazon, Google, Microsoft | |
| Word Break ↗ A prefix is breakable if it ends with a word after a breakable prefix. | 1-D Dynamic Programming | Medium | Amazon, Meta, Google | |
| Longest Increasing Subsequence ↗ Best chain ending at i, built from any smaller earlier end. | 1-D Dynamic Programming | Medium | Microsoft, Google, Amazon | |
| Pascal's Triangle ↗ Each cell is the sum of the two above it. | 2-D Dynamic Programming | Easy | Amazon, Apple | |
| Unique Paths ↗ You arrived from the top or from the left. | 2-D Dynamic Programming | Medium | Google, Amazon, Meta | |
| Minimum Path Sum ↗ Cheapest arrival from top or left. | 2-D Dynamic Programming | Medium | Amazon, Google | |
| Longest Common Subsequence ↗ Match? Go diagonal. No match? Drop a char from one side. | 2-D Dynamic Programming | Medium | Amazon, Google, Microsoft | |
| Longest Palindromic Subsequence ↗ Compare the two ends of each range. | 2-D Dynamic Programming | Medium | Amazon, LinkedIn | |
| Edit Distance ↗ Insert, delete, replace — three neighbours. | 2-D Dynamic Programming | Medium | Google, Amazon, Microsoft | |
| Distinct Subsequences ↗ On a match, you may use this char or skip it. | 2-D Dynamic Programming | Hard | Google, Amazon | |
| Regular Expression Matching ↗ A star means zero copies or one more copy. | 2-D Dynamic Programming | Hard | Google, Meta, Amazon, Microsoft |