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