Skip to content
  • Dashboard
  • Review
  • Go: plan & chat
  • Roadmap
  • Patterns & lessons49
  • Sheets
  • Problems1.5k
  • Ascend
  • Toolkit
  • Core CS + SQL
  • System Design
  • Machine Coding
  • Interview hub
  • Mock interview
  • Companies & OA
  • Leaderboard
  • Battles
  • College Cup
  • People

Keep your progress

Sync across devices with a free account.

Sign upSign in
Sheets
Sign inSign up
Sheets

128 problems · 17 topics · 43 of 49 patterns

The 128

The shortest list that still gives every interview pattern its anchor problem and its one twist.

0/128 solved43 days at 3 a dayThe 365 →
Start: Two Sum· Arrays & Hashing

Hash Map / Hash Set LookupHash map and set lookups
0/3
  • 1Two SumStore what you've seen; look up the complement in one pass.Easy
  • 49Group AnagramsThe sorted word, or its letter counts, is the key.Medium
  • 128Longest Consecutive SequenceOnly start counting from a run's first number, so it stays O(n).Medium
Boyer-Moore Majority VoteMajority vote
0/1
  • 169Majority ElementCancel pairs of different votes; the survivor is the majority.Easy
Kadane's Algorithmpart of 1D / Fibonacci-styleLearnit
0/1
  • 53Maximum SubarrayExtend the running sum or restart at this element, whichever is bigger.Medium
Simulation & Matrix TraversalMatrix and in-place tricks
0/2
  • 54Spiral MatrixShrink four walls as you peel each layer.Medium
  • 31Next PermutationRightmost dip, swap with the next bigger to its right, reverse the tail.Medium
Cyclic SortValues 1..n: put each at its own indexLearnit
0/2
  • 287Find the Duplicate NumberValues as next-pointers turn it into Floyd's cycle finding.Medium
  • 41First Missing PositiveSwap each value home; the first misfit is the answer.Hard

Two PointersOpposite ends and read/write pointersLearnit
0/5
  • 167Two Sum II - Input Array Is SortedToo small: move left up. Too big: move right down.Medium
  • 153SumFix one, two-pointer the rest, skip duplicates on every pointer.Medium
  • 11Container With Most WaterAlways move the shorter wall: keeping it can't do better.Medium
  • 42Trapping Rain WaterThe lower side's running max decides the water at that side.Hard
  • 75Sort ColorsDutch national flag: three regions, one pass.Medium

Sliding WindowVariable and fixed windowsLearnit
0/6
  • 3Longest Substring Without Repeating CharactersGrow right; shrink left while a character repeats.Medium
  • 424Longest Repeating Character ReplacementThe window is valid while length − maxFreq ≤ k.Medium
  • 567Permutation in StringFixed window of letter counts compared as it slides.Medium
  • Max Consecutive Ones IIILongest window holding at most k zeros.Medium
  • Subarray Product Less Than KEach valid window adds r − l + 1 new subarrays.Medium
  • 76Minimum Window SubstringExpand until covered, shrink to the minimum, track how many needs are met.Hard
Monotonic DequeWindow max and min with a dequeLearnit
0/1
  • 239Sliding Window MaximumA deque of indices whose values only decrease.Hard

Prefix SumPrefix sums and prefix + hash mapLearnit
0/3
  • 238Product of Array Except SelfProducts from the left times products from the right.Medium
  • 560Subarray Sum Equals KCount earlier prefixes equal to pre − k.Medium
  • 525Contiguous ArrayTurn 0 into −1: the longest zero-sum subarray.Medium
2D Prefix Sumspart of Prefix SumLearnit
0/1
  • 304Range Sum Query 2D - ImmutableInclusion–exclusion on a 2D prefix.Medium
Difference Array & Line SweepDifference arrays and sweepsLearnit
0/1
  • 1094Car Pooling+people at pickup, − at drop, then one sweep.Medium

Binary SearchOn a sorted arrayLearnit
0/5
  • 34Find First and Last Position of Element in Sorted ArrayTwo lower bounds.Medium
  • 33Search in Rotated Sorted ArrayOne half is always sorted; decide which.Medium
  • 153Find Minimum in Rotated Sorted ArrayCompare mid with the right end.Medium
  • 162Find Peak ElementWalk toward the bigger neighbour.Medium
  • 4Median of Two Sorted ArraysBinary-search the cut in the smaller array.Hard
Binary Search on the AnswerLearnit
0/4
  • 875Koko Eating BananasGuess a speed, check it, halve the range.Medium
  • 1011Capacity To Ship Packages Within D DaysThe smallest capacity that fits in D days.Medium
  • 410Split Array Largest SumMinimise the largest part (Allocate Books, Painter's Partition).Hard
  • Magnetic Force Between Two BallsMaximise the minimum gap (Aggressive Cows).Medium

String Matching (KMP / Z / Rabin-Karp)Parsing and matchingLearnit
0/3
  • 151Reverse Words in a StringSplit, reverse, join, or reverse twice in place.Medium
  • 8String to Integer (atoi)Spaces, sign, digits, overflow: in that order.Medium
  • 28Find the Index of the First Occurrence in a StringKMP's failure function.Easy
Palindromic SubstringsPalindromesLearnit
0/1
  • 5Longest Palindromic SubstringExpand around all 2n − 1 centres.Medium

In-place ReversalReversal and rewiringLearnit
0/5
  • 206Reverse Linked Listprev, curr, next: the three-pointer dance.Easy
  • 21Merge Two Sorted ListsA dummy head, then splice the smaller node.Easy
  • 25Reverse Nodes in k-GroupReverse k at a time; leave the short tail alone.Hard
  • 2Add Two NumbersDigit by digit with a carry.Medium
  • 138Copy List with Random PointerInterleave the copies, set randoms, split.Medium
Fast & Slow PointersFast and slow pointersLearnit
0/3
  • 142Linked List Cycle IIReset one to the head; they meet at the cycle's start.Medium
  • 19Remove Nth Node From End of ListKeep a gap of n between two pointers.Medium
  • 143Reorder ListMiddle + reverse + merge: three patterns in one.Medium

Stack for Matching & Expression ParsingStacks for parsing and simulation
0/4
  • 20Valid ParenthesesPush openers, match closers.Easy
  • 155Min StackStore the minimum alongside each value.Medium
  • 394Decode StringStack of (count, string so far).Medium
  • 735Asteroid CollisionPop while the incoming asteroid wins.Medium
Monotonic StackLearnit
0/4
  • 739Daily TemperaturesA stack of days still waiting for a warmer one.Medium
  • 84Largest Rectangle in HistogramEach bar's width runs to the next smaller bar on both sides.Hard
  • 402Remove K DigitsKeep the stack increasing; pop bigger digits while k lasts.Medium
  • 907Sum of Subarray MinimumsEach element's share = left span × right span.Medium

Subsets / Permutations / CombinationsSubsets, permutations, combinationsLearnit
0/4
  • 78SubsetsTake it or leave it at every index.Medium
  • 46PermutationsA used[] array, or swap into place.Medium
  • 39Combination SumReuse allowed: recurse on the same index.Medium
  • 40Combination Sum IIEach once: skip equal neighbours.Medium
BacktrackingBacktracking with pruningLearnit
0/3
  • 22Generate ParenthesesOpen while you can, close while it stays valid.Medium
  • 79Word SearchMark the cell, recurse, unmark on the way back.Medium
  • 51N-QueensSets for columns and both diagonals.Hard

Top-K ElementsTop K and greedy with a heapLearnit
0/3
  • 215Kth Largest Element in an ArrayA min-heap of size k (or quickselect).Medium
  • 347Top K Frequent ElementsCount, then a heap or buckets by frequency.Medium
  • 621Task SchedulerThe busiest task sets the frame; idle fills the gaps.Medium
Two HeapsLearnit
0/1
  • 295Find Median from Data StreamMax-heap for the low half, min-heap for the high half.Hard
K-way MergeLearnit
0/1
  • 23Merge k Sorted ListsA heap of the k list heads.Hard

Merge IntervalsIntervalsLearnit
0/3
  • 56Merge IntervalsSort by start, extend or start a new block.Medium
  • 57Insert IntervalBefore, overlapping, after: three phases.Medium
  • 435Non-overlapping IntervalsSort by end; keep the earliest finisher.Medium
GreedyGreedy choicesLearnit
0/4
  • 55Jump GameTrack the farthest reachable index.Medium
  • 45Jump Game IIBFS by levels over the reach.Medium
  • 134Gas StationIf the total is ≥ 0, start just after the worst prefix.Medium
  • 763Partition LabelsCut when you reach the last occurrence of everything seen so far.Medium

Tree DFS (Paths & Recursion)DFS and recursion on treesLearnit
0/7
  • Binary Tree Inorder TraversalRecursive first, then iterative with a stack.Easy
  • 104Maximum Depth of Binary Tree1 + max of the children.Easy
  • 226Invert Binary TreeSwap children at every node.Easy
  • 543Diameter of Binary TreeThrough each node: left height + right height.Easy
  • 236Lowest Common Ancestor of a Binary TreeThe node where both sides report a hit.Medium
  • 124Binary Tree Maximum Path SumReturn one branch up; update the answer with both.Hard
  • 863All Nodes Distance K in Binary TreeAdd parent links, then BFS from the target.Medium
Tree BFS (Level Order)Level order (BFS)Learnit
0/3
  • 102Binary Tree Level Order TraversalQueue, and the level size at the start of each round.Medium
  • 199Binary Tree Right Side ViewThe last node of each level.Medium
  • Maximum Width of Binary TreeNumber nodes 2i and 2i + 1; renumber per level.Medium
BST LogicBinary search treesLearnit
0/2
  • 98Validate Binary Search TreePass (low, high) bounds down.Medium
  • 230Kth Smallest Element in a BSTInorder is sorted; stop at the k-th.Medium
Tree Construction & SerializationBuilding and serialising treesLearnit
0/2
  • 105Construct Binary Tree from Preorder and Inorder TraversalPreorder gives the root; inorder splits the sides.Medium
  • 297Serialize and Deserialize Binary TreePreorder with null markers.Hard

Trie (Prefix Tree)Prefix treesLearnit
0/3
  • 208Implement Trie (Prefix Tree)Children plus an end-of-word flag.Medium
  • 212Word Search IITrie + backtracking; remove words once found.Hard
  • 421Maximum XOR of Two Numbers in an ArrayA bit trie: always try the opposite bit.Medium

Graph BFS / DFSBFS and DFSLearnit
0/3
  • 200Number of IslandsCount the DFS starts.Medium
  • 133Clone GraphA map from old node to new node.Medium
  • 417Pacific Atlantic Water FlowSearch uphill from each ocean, intersect.Medium
Multi-source BFSBFS shortest paths · part of Graph BFS / DFSLearnit
0/2
  • 994Rotting OrangesPut every rotten orange in the queue first.Medium
  • 127Word LadderWords are nodes; neighbours differ by one letter.Hard
Bipartite Check / 2-ColouringBipartite check · part of Graph BFS / DFSLearnit
0/1
  • 785Is Graph Bipartite?2-colour with BFS; a same-colour edge fails.Medium
Topological SortLearnit
0/2
  • 207Course ScheduleKahn's algorithm: if not every node comes out, there's a cycle.Medium
  • 210Course Schedule IIThe order Kahn's produces.Medium
Union-Find (Disjoint Set)Union–Find (DSU)Learnit
0/2
  • 684Redundant ConnectionThe first edge joining two already-connected nodes.Medium
  • 721Accounts MergeUnion by shared email.Medium
Dijkstra (Weighted Shortest Path)DijkstraLearnit
0/1
  • 743Network Delay TimeDijkstra from one source; the answer is the max distance.Medium
Bellman-FordBellman–FordLearnit
0/1
  • 787Cheapest Flights Within K Stopsk + 1 rounds of relaxation from a copy.Medium
Floyd-WarshallFloyd–WarshallLearnit
0/1
  • 1334Find the City With the Smallest Number of Neighbors at a Threshold DistanceEvery pair's distance, then count.Medium
Minimum Spanning TreeLearnit
0/1
  • 1584Min Cost to Connect All PointsPrim's on a complete graph, or Kruskal's with DSU.Medium

1D / Fibonacci-style1D DPLearnit
0/4
  • 198House RobberRob i and skip i − 1, or skip i.Medium
  • 213House Robber IIThe circle: run it twice, without the first and without the last.Medium
  • 91Decode WaysOne digit or two, with zero rules.Medium
  • 139Word Breakdp[i] = some dictionary word ends at i after a true dp[j].Medium
Grid / Matrix DPGrid DPLearnit
0/2
  • 62Unique PathsFrom the top and from the left.Medium
  • 64Minimum Path SumMin of top and left, plus the cell.Medium
0/1 KnapsackLearnit
0/2
  • 416Partition Equal Subset SumCan a subset reach total / 2?Medium
  • 494Target SumCount subsets summing to (total + target) / 2.Medium
Unbounded KnapsackLearnit
0/2
  • 322Coin ChangeFewest coins: min over coins of dp[a − c] + 1.Medium
  • 518Coin Change IICoins in the outer loop count combinations.Medium
LCS / Two-SequenceTwo-string DPLearnit
0/2
  • 1143Longest Common SubsequenceMatch: diagonal + 1. Else: the max of top and left.Medium
  • 72Edit DistanceInsert, delete, replace: the min of three neighbours.Medium
Longest Increasing SubsequenceLearnit
0/1
  • 300Longest Increasing SubsequenceO(n²) first, then tails + binary search.Medium
Interval DPLearnit
0/1
  • 312Burst BalloonsChoose the last balloon to burst in (l, r).Hard
State Machine DP (Stocks)State machine DPLearnit
0/2
  • 121Best Time to Buy and Sell StockTrack the cheapest day so far.Easy
  • Maximum Profit in Job SchedulingSort by end; take a job plus the best ending before it.Hard

Bit Tricks & BitmaskingBit manipulationLearnit
0/2
  • 136Single NumberXOR everything; pairs cancel.Easy
  • 260Single Number IIISplit the numbers on the lowest bit where the two differ.Medium
Math / Number TheoryMath and number theoryLearnit
0/2
  • 204Count PrimesSieve of Eratosthenes.Medium
  • 50Pow(x, n)Fast power: square and halve; careful with negative n.Medium

System / DS DesignData-structure designLearnit
0/3
  • 146LRU CacheHash map + doubly linked list.Medium
  • 380Insert Delete GetRandom O(1)Array + index map; delete by swapping with the last.Medium
  • 981Time Based Key-Value StorePer-key sorted timestamps + binary search.Medium
TodayReviewPatternsProblems