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

DoneProblemPatternLevelCompanies
Valid Palindrome ↗

Compare characters from both ends, skipping non-alphanumerics.

Two PointersEasyMeta, Microsoft, Amazon
Move Zeroes ↗

One pointer reads, another marks where the next non-zero goes.

Two PointersEasyMeta, Amazon, Apple
Squares of a Sorted Array ↗

The biggest square is always at one of the two ends.

Two PointersEasyAmazon, Google
Two Sum II - Input Array Is Sorted ↗

Sum too big? Only one pointer can fix that.

Two PointersMediumAmazon, Google, Meta
3Sum ↗

Fix one number, then it's Two Sum II on the rest.

Two PointersMediumMeta, Amazon, Google, Microsoft
Container With Most Water ↗

The shorter wall limits the area — which one is worth moving?

Two PointersMediumAmazon, Google, Meta
Sort Colors ↗

Three regions, three pointers, one pass.

Two PointersMediumMicrosoft, Amazon
Trapping Rain Water ↗

Water at a spot depends on the smaller of the tallest walls on each side.

Two PointersHardAmazon, Google, Goldman Sachs, Meta
Maximum Average Subarray I ↗

Fixed width: add the new element, drop the old one.

Sliding WindowEasyGoogle, Amazon
Longest Substring Without Repeating Characters ↗

When a repeat enters, pull the left edge past it.

Sliding WindowMediumAmazon, Google, Meta, Microsoft
Minimum Size Subarray Sum ↗

All positives — once the sum is big enough, shrink.

Sliding WindowMediumMeta, Amazon
Fruit Into Baskets ↗

Longest window with at most two distinct values.

Sliding WindowMediumGoogle, Amazon
Longest Repeating Character Replacement ↗

Window is valid while length minus its most common char ≤ k.

Sliding WindowMediumGoogle, Amazon, Uber
Permutation in String ↗

Fixed window of len(s1); compare letter counts.

Sliding WindowMediumMicrosoft, Meta
Minimum Window Substring ↗

Expand until every needed char is covered, then shrink greedily.

Sliding WindowHardMeta, Amazon, Google, LinkedIn
Sliding Window Maximum ↗

Keep only indices that could still become the max.

Sliding WindowHardAmazon, Google, Microsoft
Find Pivot Index ↗

Left sum vs total minus left minus current.

Prefix Sum + Hash MapEasyAmazon, Meta
Range Sum Query - Immutable ↗

Precompute once, answer each query by subtraction.

Prefix Sum + Hash MapEasyMeta, Amazon
Subarray Sum Equals K ↗

Which earlier running total would make this one work?

Prefix Sum + Hash MapMediumMeta, Amazon, Google, Microsoft
Contiguous Array ↗

Treat 0 as -1; you're now looking for sum 0.

Prefix Sum + Hash MapMediumMeta, Amazon
Continuous Subarray Sum ↗

Same remainder twice, at least two apart.

Prefix Sum + Hash MapMediumMeta, Amazon
Subarray Sums Divisible by K ↗

Count prefix remainders, not prefix sums.

Prefix Sum + Hash MapMediumMeta, Amazon
Count Number of Nice Subarrays ↗

Map each number to 1 if odd, 0 if even — familiar now?

Prefix Sum + Hash MapMediumGoogle, Amazon
Number of Submatrices That Sum to Target ↗

Fix a pair of rows, collapse columns, reuse the 1-D trick.

Prefix Sum + Hash MapHardGoogle, Meta
Binary Search ↗

Compare to the middle, discard half.

Binary SearchEasyGoogle, Microsoft
Search Insert Position ↗

First index whose value is ≥ target.

Binary SearchEasyAmazon, Apple
First Bad Version ↗

Good…good, bad…bad — find the first bad.

Binary SearchEasyMeta, Microsoft
Find First and Last Position of Element in Sorted Array ↗

Two lower-bound searches: for target and target + 1.

Binary SearchMediumMeta, Amazon, LinkedIn
Search in Rotated Sorted Array ↗

One side of mid is always sorted.

Binary SearchMediumMeta, Amazon, Microsoft, LinkedIn
Koko Eating Bananas ↗

Search over speeds; can she finish in time?

Binary SearchMediumGoogle, Amazon, Airbnb
Capacity To Ship Packages Within D Days ↗

Guess a capacity, simulate the days.

Binary SearchMediumAmazon, Google
Median of Two Sorted Arrays ↗

Binary search the cut position in the smaller array.

Binary SearchHardGoogle, Amazon, Goldman Sachs, Apple
Next Greater Element I ↗

Precompute next-greater for nums2 once.

Monotonic StackEasyAmazon, Bloomberg
Daily Temperatures ↗

Who's still waiting for a warmer day?

Monotonic StackMediumAmazon, Meta, Google
Online Stock Span ↗

Collapse smaller previous prices into the current one.

Monotonic StackMediumAmazon, Microsoft
Next Greater Element II ↗

Walk the array twice.

Monotonic StackMediumAmazon, Google
Remove K Digits ↗

A bigger digit before a smaller one should go.

Monotonic StackMediumAmazon, Microsoft
Sum of Subarray Minimums ↗

For each element: how far left and right is it the minimum?

Monotonic StackMediumAmazon, Google
Largest Rectangle in Histogram ↗

A bar's rectangle ends at the first shorter bar on each side.

Monotonic StackHardAmazon, Google, Microsoft
Maximal Rectangle ↗

Each row is the base of a histogram.

Monotonic StackHardGoogle, Meta
Summary Ranges ↗

Build ranges while the next number continues the run.

Merge IntervalsEasyGoogle, Meta
Merge Intervals ↗

After sorting, who can the next interval possibly overlap?

Merge IntervalsMediumMeta, Google, Amazon, Microsoft
Insert Interval ↗

Three phases: before, overlapping, after.

Merge IntervalsMediumGoogle, LinkedIn, Meta
Non-overlapping Intervals ↗

Keep the one that ends first.

Merge IntervalsMediumMeta, Amazon
Minimum Number of Arrows to Burst Balloons ↗

Shoot at the earliest end point.

Merge IntervalsMediumAmazon, Microsoft
Interval List Intersections ↗

Two pointers; advance whoever finishes first.

Merge IntervalsMediumMeta, Uber
Car Pooling ↗

Passengers on at start, off at end — track the peak.

Merge IntervalsMediumGoogle, Lyft
Data Stream as Disjoint Intervals ↗

Keep intervals sorted; a new number can join neighbours.

Merge IntervalsHardGoogle, Amazon
Assign Cookies ↗

Smallest cookie that satisfies the least greedy child.

GreedyEasyAmazon
Best Time to Buy and Sell Stock II ↗

Collect every upward step.

GreedyMediumAmazon, Bloomberg, Meta
Jump Game ↗

Track how far you could get.

GreedyMediumAmazon, Meta, Microsoft
Jump Game II ↗

Think of reachable ranges as BFS levels.

GreedyMediumAmazon, Google
Gas Station ↗

If you run dry at i, every start before i fails too.

GreedyMediumAmazon, Google, Bloomberg
Partition Labels ↗

A part can't end before the last occurrence of any letter in it.

GreedyMediumAmazon, Meta
Hand of Straights ↗

The smallest card must start a group.

GreedyMediumGoogle
Candy ↗

Two passes: left neighbours, then right neighbours.

GreedyHardAmazon, Microsoft
Linked List Cycle ↗

Will a faster runner ever catch a slower one?

Fast & Slow PointersEasyAmazon, Microsoft, Bloomberg
Middle of the Linked List ↗

Half speed lands halfway.

Fast & Slow PointersEasyAmazon, Apple
Happy Number ↗

The digit-square process is a hidden linked list.

Fast & Slow PointersEasyGoogle, Apple
Palindrome Linked List ↗

Find the middle, then compare halves.

Fast & Slow PointersEasyMeta, Amazon, Microsoft
Linked List Cycle II ↗

After meeting, restart one pointer from head.

Fast & Slow PointersMediumAmazon, Microsoft
Remove Nth Node From End of List ↗

Give one pointer an n-step head start.

Fast & Slow PointersMediumMeta, Amazon, Google
Reorder List ↗

Middle, reverse second half, weave.

Fast & Slow PointersMediumMeta, Amazon
Find the Duplicate Number ↗

Indices as nodes, values as next pointers.

Fast & Slow PointersMediumGoogle, Amazon, Microsoft
Reverse Linked List ↗

Three references are all you need.

In-place ReversalEasyAmazon, Microsoft, Apple, Meta
Reverse Linked List II ↗

Anchor the node just before the segment.

In-place ReversalMediumMeta, Amazon, Microsoft
Swap Nodes in Pairs ↗

It's reversal with k = 2.

In-place ReversalMediumAmazon, Microsoft
Rotate List ↗

Close it into a ring, then cut at the right spot.

In-place ReversalMediumAmazon, LinkedIn
Maximum Twin Sum of a Linked List ↗

Reverse the second half and walk both halves together.

In-place ReversalMediumAmazon
Reverse Nodes in k-Group ↗

Count k ahead before you flip anything.

In-place ReversalHardAmazon, Microsoft, Meta, Google
Kth Largest Element in a Stream ↗

Keep only k seats on stage.

Heap / Top-KEasyAmazon, Meta
Last Stone Weight ↗

Always grab the two heaviest.

Heap / Top-KEasyAmazon, Google
Kth Largest Element in an Array ↗

You don't need the whole array sorted.

Heap / Top-KMediumMeta, Amazon, Microsoft, LinkedIn
Top K Frequent Elements ↗

Count first, then keep the best k counts.

Heap / Top-KMediumAmazon, Meta, Google
K Closest Points to Origin ↗

Keep the k smallest distances — which heap evicts the farthest?

Heap / Top-KMediumMeta, Amazon, LinkedIn
Task Scheduler ↗

Always run the most frequent available task.

Heap / Top-KMediumMeta, Amazon, Microsoft
Merge k Sorted Lists ↗

The next output node is the smallest of k heads.

Heap / Top-KHardAmazon, Meta, Google, Microsoft
Find Median from Data Stream ↗

Two heaps facing each other.

Heap / Top-KHardAmazon, Google, Microsoft
Minimum Depth of Binary Tree ↗

The first leaf you meet floor by floor wins.

Tree BFS (Level Order)EasyAmazon, Meta
Average of Levels in Binary Tree ↗

Sum and count per level.

Tree BFS (Level Order)EasyMeta, Amazon
Binary Tree Level Order Traversal ↗

Freeze the queue length at the start of each floor.

Tree BFS (Level Order)MediumAmazon, Meta, Microsoft, LinkedIn
Binary Tree Right Side View ↗

Who's last on each floor?

Tree BFS (Level Order)MediumMeta, Amazon, Bloomberg
Binary Tree Zigzag Level Order Traversal ↗

Same BFS, flip direction each level.

Tree BFS (Level Order)MediumAmazon, Microsoft, Bloomberg
Populating Next Right Pointers in Each Node ↗

Neighbours on the same floor are adjacent in the queue.

Tree BFS (Level Order)MediumMicrosoft, Amazon
Maximum Width of Binary Tree ↗

Number positions like a heap: 2i and 2i+1.

Tree BFS (Level Order)MediumAmazon, Google
Serialize and Deserialize Binary Tree ↗

Level order with explicit null markers.

Tree BFS (Level Order)HardAmazon, Meta, Google, LinkedIn
Maximum Depth of Binary Tree ↗

Ask both children, take the bigger, add one.

Tree DFS (Recursion)EasyAmazon, LinkedIn, Microsoft
Invert Binary Tree ↗

Swap, then let recursion handle the rest.

Tree DFS (Recursion)EasyGoogle, Amazon
Diameter of Binary Tree ↗

Return height, but record left + right.

Tree DFS (Recursion)EasyMeta, Amazon, Google
Balanced Binary Tree ↗

Compute height and balance in the same pass.

Tree DFS (Recursion)EasyAmazon, Bloomberg
Validate Binary Search Tree ↗

Every node lives inside a range set by its ancestors.

Tree DFS (Recursion)MediumAmazon, Meta, Microsoft, Bloomberg
Lowest Common Ancestor of a Binary Tree ↗

If both sides report a hit, you're the answer.

Tree DFS (Recursion)MediumMeta, Amazon, Microsoft, LinkedIn
Path Sum II ↗

Carry the remaining target down; undo on the way back.

Tree DFS (Recursion)MediumAmazon, Meta
Binary Tree Maximum Path Sum ↗

Return the best single arm; record the best bend.

Tree DFS (Recursion)HardMeta, Amazon, Google, Microsoft
Flood Fill ↗

Spread from one cell to same-coloured neighbours.

Graph BFS / DFS (Grids)EasyAmazon, Microsoft
Number of Islands ↗

Each new paint bucket is one island.

Graph BFS / DFS (Grids)MediumAmazon, Meta, Google, Microsoft
Max Area of Island ↗

Count cells while you flood.

Graph BFS / DFS (Grids)MediumAmazon, Google
Rotting Oranges ↗

All rotten oranges spread at the same time.

Graph BFS / DFS (Grids)MediumAmazon, Microsoft, Google
Surrounded Regions ↗

What's safe is connected to the border.

Graph BFS / DFS (Grids)MediumGoogle, Amazon
Pacific Atlantic Water Flow ↗

Let water flow uphill from each ocean.

Graph BFS / DFS (Grids)MediumGoogle, Amazon
Clone Graph ↗

Map old node → new node as you traverse.

Graph BFS / DFS (Grids)MediumMeta, Google, Amazon
Word Ladder ↗

Words are nodes; one-letter changes are edges; shortest path.

Graph BFS / DFS (Grids)HardAmazon, Meta, Google, LinkedIn
Course Schedule ↗

Can every course's blockers eventually clear?

Topological SortMediumAmazon, Meta, Google, Microsoft
Course Schedule II ↗

Record the order in which blockers clear.

Topological SortMediumAmazon, Meta, Google
Find All Possible Recipes from Given Supplies ↗

Ingredients are prerequisites of recipes.

Topological SortMediumGoogle, Amazon
Find Eventual Safe States ↗

Reverse the edges and peel off nodes with no outgoing paths.

Topological SortMediumGoogle, Amazon
Course Schedule IV ↗

Propagate prerequisite sets in topological order.

Topological SortMediumGoogle, Amazon
Minimum Height Trees ↗

Peel leaves layer by layer toward the centre.

Topological SortMediumGoogle, Amazon
Parallel Courses III ↗

Earliest finish = own time + latest-finishing prerequisite.

Topological SortHardGoogle, Amazon
Sort Items by Groups Respecting Dependencies ↗

Two levels of topological sort: groups, then items.

Topological SortHardGoogle
Find if Path Exists in Graph ↗

Same leader means same group.

Union-Find (DSU)EasyAmazon, Google
Number of Provinces ↗

Start with n groups; each real merge removes one.

Union-Find (DSU)MediumAmazon, Meta, Google
Redundant Connection ↗

Which edge joins two already-joined nodes?

Union-Find (DSU)MediumGoogle, Amazon
Number of Operations to Make Network Connected ↗

Spare cables vs components minus one.

Union-Find (DSU)MediumAmazon, Microsoft
Satisfiability of Equality Equations ↗

Union all '==' first, then check every '!='.

Union-Find (DSU)MediumGoogle
Accounts Merge ↗

Emails are nodes; an account unions its emails.

Union-Find (DSU)MediumMeta, Google, Amazon
Most Stones Removed with Same Row or Column ↗

Answer = stones minus number of groups.

Union-Find (DSU)MediumGoogle, Amazon
Swim in Rising Water ↗

Add cells by height until corners connect.

Union-Find (DSU)HardGoogle, Amazon
Binary Tree Paths ↗

Extend the path going down, trim it coming back.

BacktrackingEasyGoogle, Meta
Subsets ↗

Each element: in or out.

BacktrackingMediumMeta, Amazon, Google
Permutations ↗

Any unused element can go in the next slot.

BacktrackingMediumMicrosoft, Amazon, LinkedIn
Combination Sum ↗

You may pick the same number again — where does the next call start?

BacktrackingMediumAirbnb, Amazon, Uber
Subsets II ↗

Sort, then skip equal siblings.

BacktrackingMediumAmazon, Meta
Letter Combinations of a Phone Number ↗

One digit per level of the tree.

BacktrackingMediumAmazon, Meta, Uber
Word Search ↗

Mark a cell while it's on the path, unmark on the way back.

BacktrackingMediumAmazon, Microsoft, Meta
N-Queens ↗

One queen per row; track used columns and diagonals.

BacktrackingHardAmazon, Google, Microsoft
Climbing Stairs ↗

How could you have arrived at the last step?

1-D Dynamic ProgrammingEasyAmazon, Google, Adobe
Min Cost Climbing Stairs ↗

Cheapest way to stand on step i.

1-D Dynamic ProgrammingEasyAmazon
House Robber ↗

Rob this one plus two back, or skip it.

1-D Dynamic ProgrammingMediumAmazon, Google, Cisco
House Robber II ↗

Break the circle two different ways.

1-D Dynamic ProgrammingMediumAmazon, Microsoft
Decode Ways ↗

Last char alone, or last two together?

1-D Dynamic ProgrammingMediumMeta, Google, Amazon
Coin Change ↗

Which coin did you use last?

1-D Dynamic ProgrammingMediumAmazon, Google, Microsoft
Word Break ↗

A prefix is breakable if it ends with a word after a breakable prefix.

1-D Dynamic ProgrammingMediumAmazon, Meta, Google
Longest Increasing Subsequence ↗

Best chain ending at i, built from any smaller earlier end.

1-D Dynamic ProgrammingMediumMicrosoft, Google, Amazon
Pascal's Triangle ↗

Each cell is the sum of the two above it.

2-D Dynamic ProgrammingEasyAmazon, Apple
Unique Paths ↗

You arrived from the top or from the left.

2-D Dynamic ProgrammingMediumGoogle, Amazon, Meta
Minimum Path Sum ↗

Cheapest arrival from top or left.

2-D Dynamic ProgrammingMediumAmazon, Google
Longest Common Subsequence ↗

Match? Go diagonal. No match? Drop a char from one side.

2-D Dynamic ProgrammingMediumAmazon, Google, Microsoft
Longest Palindromic Subsequence ↗

Compare the two ends of each range.

2-D Dynamic ProgrammingMediumAmazon, LinkedIn
Edit Distance ↗

Insert, delete, replace — three neighbours.

2-D Dynamic ProgrammingMediumGoogle, Amazon, Microsoft
Distinct Subsequences ↗

On a match, you may use this char or skip it.

2-D Dynamic ProgrammingHardGoogle, Amazon
Regular Expression Matching ↗

A star means zero copies or one more copy.

2-D Dynamic ProgrammingHardGoogle, Meta, Amazon, Microsoft