Data Structures and Algorithm
We deliberately don't cover every DSA topic. Learn the structures, techniques, and patterns that actually get asked in interviews with a step-by-step visualizer and real practice problems for each one.
Foundations
The data structures every pattern below is built on.
Arrays
The default choice for ordered data: constant-time index access, linear-time search.
Strings
Arrays of characters with their own quirks: immutability, encoding, and O(n) concatenation traps.
HashMap
Key-value lookups in average O(1) time: the single most useful trick for turning O(n²) into O(n).
HashSet
A HashMap that only cares about keys: average O(1) membership checks with no duplicates.
Stack
Last-in, first-out: the structure behind parsing, backtracking, and matching problems.
Queue
First-in, first-out ordering: the backbone of BFS, task scheduling, and streaming problems.
Linked List
Nodes chained by pointers: cheap inserts and deletes at the cost of random access.
Trees
Hierarchical nodes with parent-child links: the shape behind DOM trees, ASTs, and search structures.
Graphs
Nodes and edges without the hierarchy constraint: the model behind networks, dependencies, and maps.
Heap / Priority Queue
A complete binary tree stored in an array: gives you the min or max in O(1), always.
Techniques
General-purpose techniques that show up across many problems.
Recursion
Solve a problem by expressing it in terms of a smaller version of itself, until you hit a base case.
Bit Manipulation
Operate directly on the binary representation of numbers for constant-time tricks and tight space usage.
Sorting
Reorder data so that later algorithms (search, dedup, greedy choices) become simpler and faster.
Interview Patterns
The core curriculum — recognize these and most interview problems fall into place.
Two Pointers
Walk two indices through a sorted structure in tandem to cut a quadratic search down to linear time.
Sliding Window
Track a moving range over an array or string to turn brute-force O(n^2) scans into a single O(n) pass.
Prefix Sum
Precompute running totals so any range sum becomes an O(1) lookup instead of a fresh loop every time.
Frequency Counting
Tally occurrences with a hash map or fixed-size array to turn comparison and grouping problems into linear-time lookups.
Binary Search
Cut the search space in half every step: the go-to pattern for sorted arrays, rotated arrays, and 'search on the answer' problems.
Merge Intervals
Sort by start time, then sweep once: the standard playbook for overlapping ranges, scheduling, and booking problems.
Fast & Slow Pointers
Two pointers moving at different speeds through a sequence: the constant-space trick for cycle detection and finding the middle.
Tree Depth-First Search
Recurse into left and right subtrees to explore paths, validate properties, and compute tree-wide values.
Tree Breadth-First Search
Traverse a binary tree level by level using a queue: the go-to pattern for level order, right-side view, and shortest-depth problems.
Graph Depth-First Search
Explore a graph as deep as possible before backtracking: the pattern behind connected components, cycle detection, and flood fill.
Graph Breadth-First Search
Expand outward in waves from a source using a queue: the pattern for shortest paths, multi-source spread, and minimum-step problems.
Top K Elements
Find the K largest, smallest, or most frequent elements without fully sorting the input, powered by a heap of size K.
Two Heaps
Split a stream into a max-heap of smaller values and a min-heap of larger values to get the median or a running order statistic in O(log n) per operation.
Backtracking
Explore every candidate solution by choosing, recursing, and un-choosing, pruning branches the moment they can't possibly lead to a valid answer.
Dynamic Programming
Break a problem into overlapping subproblems, solve each one once, and reuse the answer, turning exponential brute force into polynomial time.
Greedy Algorithms
Make the locally optimal choice at every step and never look back: valid only when a local best provably leads to a global best.