Skip to content

DSA-light

Data structures and algorithms at medium level: Big-O of JavaScript built-ins, hash maps, stacks, heaps, two pointers, binary search, BFS/DFS and memoization.

8 lessons

Complexity and core structures

  1. 1Big-O and the real cost of JS built-insCount what the loop body does per item; a scan or a shift inside a loop multiplies, a Set lookup does not.
  2. 2Hash-map patterns: count, group, indexPick the shape (count, group or index), choose the key, and use a Map unless the keys are plain strings.
  3. 3Stacks and queuesChoose by which entry must come back next; then make taking it move nothing.
  4. 4Heaps and top-KA heap orders only each parent against its children, and that is enough to keep the smallest value at the front.

Medium patterns

  1. 5Two pointers and sliding windowEach index only moves one way; a window also needs a rule that changes one way as it grows.
  2. 6Binary search, including on the answerName the check that flips once; keep lo on a no and hi on a yes.
  3. 7BFS and DFS on trees and graphsTree code on a graph repeats or loops; a visited set makes each node one visit, and a path set finds the cycles.
  4. 8Recursion and memoizationName each subproblem by everything it reads, compute it once, and count the calls you leave waiting.