Learn › Data Structures & Algorithms
🧩 Data Structures & Algorithms
The 18 patterns that cover ~90% of startup SDE-2 DSA. Quality over grind.
Goal
Recognize the pattern instantly and code the template without bugs. 01
Arrays & Hashing
easy ⏱ 30m 02 Frequency counting, seen-sets, and prefix products — the warm-up category that unlocks O(1) lookups and turns quadratic scans into linear.
Two Pointers
medium ⏱ 28m 03 Opposite-end and read/write pointers — clean, optimal, O(n)/O(1) solutions and a startup favorite. Your move-zeros gap lives here.
Sliding Window
medium ⏱ 28m 04 Fixed and variable windows over a sequence — turn O(n·k) substring/subarray scans into O(n).
Binary Search
medium ⏱ 28m 05 The template that kills off-by-one bugs, plus 'search on the answer' — the variant that trips people up.
Trees & BSTs
medium ⏱ 32m 06 DFS (pre/in/post) as recursion, BFS as a queue, and the BST invariant — recursion fluency, tested constantly.
Graphs
medium ⏱ 32m 07 BFS/DFS on grids and adjacency lists, connected components, topological sort, and union-find — the startup staples.
Dynamic Programming
hard ⏱ 36m 08 Spot overlapping subproblems, define the state, write the recurrence — then memoize or tabulate. Templates for 1D, 2D, knapsack, LIS, and grids.
Heaps & Priority Queues
medium ⏱ 28m 09 Top-K, streaming medians, and merge-k-sorted with a heap — O(log n) access to the smallest/largest, and the two-heap balance trick.
Linked Lists
medium ⏱ 30m 10 The dummy-head technique, fast/slow pointers for cycles and middles, and clean in-place reversal — pointer fluency under pressure.
Stack & Queue
medium ⏱ 30m 11 LIFO/FIFO mechanics, the monotonic stack for next-greater problems, min-stack, and sliding-window-max via a deque.
Backtracking
hard ⏱ 32m 12 The choose / explore / un-choose template, decision-tree thinking, and pruning — the engine behind subsets, permutations, combinations, and N-Queens.
Intervals
medium ⏱ 26m The sort-by-start trick, merging overlaps, insert interval, non-overlapping removal, and meeting-rooms scheduling with a heap.