Skip to content
16-Week DSA Roadmap

Study guide

Learn the patterns, one picture at a time

Every problem in weeks 1–4, explained for complete beginners: the idea in plain English, an animated step-by-step walkthrough, and the solution in JavaScript and Python with every line explained.

How to use this guide

  1. 1

    Read the week overview first

    It explains the data structures and patterns in plain English, with templates in JavaScript and Python.

  2. 2

    Try each problem before reading

    Open it on LeetCode, think for 20–30 minutes, and only then read the study page. Struggling first is how it sticks.

  3. 3

    Play the visualizations

    Step through them slowly. Read each caption: it says what happens and why. Then predict the next step before you press Next.

  4. 4

    Re-type the code, don't copy it

    Close the page and write the solution from memory in your language. Mark it complete when you can.

The four weeks

Week 1

Arrays & Hashing

Arrays, hash maps and hash sets, the tools behind almost every interview problem, explained from zero.
  • Hash set membership
  • Frequency counting
  • Hash map lookup
  • Grouping by a canonical key
  • Bucket sort by frequency
  • Prefix and suffix products
  • Encoding constraints as set keys
  • Find the start of a sequence

Contains Duplicate · Valid Anagram · Two Sum · Group Anagrams · Top K Frequent Elements · Product of Array Except Self · Valid Sudoku · Longest Consecutive Sequence

8 of 8 pages ready

Week 2

Two Pointers & Sliding Window

Walk through an array or string with two fingers instead of one, and turn many slow "check every pair" problems into a single fast pass.
  • Converging two pointers
  • Sort first, then two pointers
  • Greedy pointer move
  • Track the best so far in one pass
  • Variable-size sliding window
  • Window with counts and a validity check
  • Fixed-size sliding window

Valid Palindrome · Two Sum II - Input Array Is Sorted · Container With Most Water · 3Sum · Best Time to Buy and Sell Stock · Longest Substring Without Repeating Characters · Longest Repeating Character Replacement · Permutation in String

8 of 8 pages ready

Week 3

Stack & Binary Search

Two small tools with a huge reach. A stack remembers the most recent unfinished thing; binary search finds things in sorted data by halving the search every step.
  • Stack for matching pairs
  • Auxiliary stack (running min or max)
  • Stack-based expression evaluation
  • Monotonic stack
  • Sort, then stack to merge groups
  • Classic binary search
  • 2D matrix as a 1D sorted array
  • Binary search on a rotated array

Valid Parentheses · Min Stack · Evaluate Reverse Polish Notation · Daily Temperatures · Car Fleet · Binary Search · Search a 2D Matrix · Find Minimum in Rotated Sorted Array

8 of 8 pages ready

Week 4

Binary Search & Linked Lists

Three new twists on binary search, then linked lists from zero, with the pointer patterns (reverse, dummy node, fast and slow, gap) that solve almost every list problem.
  • Binary search on a rotated array
  • Binary search on the answer
  • Binary search over sorted timestamps
  • Reversing a linked list
  • Dummy (sentinel) head node
  • Fast and slow pointers
  • Two pointers with a gap
  • Combining patterns

Search in Rotated Sorted Array · Koko Eating Bananas · Time Based Key-Value Store · Reverse Linked List · Merge Two Sorted Lists · Linked List Cycle · Remove Nth Node From End of List · Reorder List

8 of 8 pages ready

How to read the visualizations

Every picture uses the same colours, so once you learn them here they mean the same thing on every page. Boxes are values, and the small numbers under them are theirindexes (positions, starting at 0). Labelled arrows like i arepointers: variables that remember a position.

nums
  1. 40
  2. 11
  3. 52
  4. 33
seen3 items

look up 5: found

numberindex
40
11
52
  • Looking at now
  • Comparing with
  • Answer
  • Not found
  • Just added
  • Inside the window
  • Already processed
  • Ignored
  • Controls: Play runs the steps automatically; Next and Previous move one step; the slider jumps anywhere. Click the player, then use ← → and the space bar.
  • Caption: the sentence under the picture explains what just happened and why. Read it every step.
  • Code panel: the highlighted line is the one running right now. Switch between JavaScript and Python anywhere and the choice is remembered on every page.