A blog series

DSA for Interviews, From Zero

Data structures and algorithms for coding interviews, starting from the very first loop. Every idea is traced step by step and then practised on interview-style questions with full answers, so that it stays with you long term.

Started 
2026
Progress 
60 / 60 lessons
Parts 
15
Language 
JavaScript

How the series is organised

Fifteen parts, each building on the one before. Never written a loop? Start at Lesson 01 — it assumes nothing. Already comfortable with loops and arrays? Jump to Part 2.

  1. 1Programming From ZeroVariables, conditions, for and while loops, functions, arrays, strings and maps — in JavaScript, traced line by line.Lessons 1–10
  2. 2Thinking Like a Problem-SolverReading a problem, Big-O, basic maths, your first recursion and counting with a hash map.Lessons 11–15
  3. 3SortingSelection, bubble and insertion sort to understand sorting; merge and quick sort to use it.Lessons 16–18
  4. 4Arrays and the First PatternsPrefix sums, two pointers, sliding windows, Kadane's algorithm and matrices.Lessons 19–25
  5. 5Hashing PatternsTwo Sum, the “seen before?” technique, frequency maps and grouping.Lessons 26–27
  6. 6Binary SearchHalving a sorted array, then binary search on the answer.Lessons 28–29
  7. 7StringsPalindromes, reversing, counting and substring windows.Lessons 30–31
  8. 8Recursion and BacktrackingRecursion trees, subsets, permutations and standard backtracking problems.Lessons 32–34
  9. 9Linked ListsBuild one, reverse it, and the fast/slow pointer pattern.Lessons 35–37
  10. 10Stacks and QueuesValid parentheses, queues, deques and the monotonic stack.Lessons 38–40
  11. 11TreesTraversals, BFS and DFS on trees, binary search trees, LCA.Lessons 41–45
  12. 12Heaps, Greedy and IntervalsTop-K with heaps, greedy choices and interval merging.Lessons 46–48
  13. 13GraphsStoring graphs, BFS/DFS, topological sort, shortest paths, union-find.Lessons 49–53
  14. 14Dynamic ProgrammingFrom recursion to memoisation, then 1-D, 2-D and string DP.Lessons 54–57
  15. 15Extras and the InterviewTries, bit tricks, the interview playbook and a revision plan.Lessons 58–60

How every lesson works

  1. The idea in plain words — a real-life picture before any code.
  2. A dry run — every variable written down at every step, plus an interactive tracer you can step through.
  3. Interview-style questions — each with examples, a hint, and a full answer with the reasoning. Try first, then open the answer.
  4. Make it stick — a short recall exercise and a revisit schedule (tomorrow, 3 days, a week), because recalling beats re-reading.

Contents

Part 1 · Programming From Zero

Variables, conditions, for and while loops, functions, arrays, strings and maps — in JavaScript, traced line by line.

  1. Lesson 01What a Program Is, and How to Run OneA program is a list of instructions run top to bottom. Run your first JavaScript, read its output, and learn to predict exactly what prints.Topics · What a program and a statement are · Running JavaScript: browser console, Node.js, a .js file · console.log and printing several values · Top-to-bottom execution order · Comments · Reading errors: SyntaxError, ReferenceError, TypeError · The dry-run habit: predict, then run12 min
  2. Lesson 02Variables and Data TypesNamed boxes for values: numbers, strings and booleans, and the operators that combine them — including % and Math.floor, which appear in almost every DSA problem.Topics · let and const · Naming rules and camelCase · number, string, boolean, undefined, null and typeof · Arithmetic operators and their order · % (remainder) and Math.floor (whole division) · Useful Math functions: abs, min, max, round, sqrt · Joining text and template literals · Converting between text and numbers · Shorthand operators: +=, ++16 min
  3. Lesson 03Conditions: if / elseTeach the program to make decisions. Comparisons, && and ||, else-if chains, and common questions: even or odd, largest of three, leap year.Topics · Comparison operators and === vs == · if, else and else-if chains · Logical operators &&, || and ! · Short-circuit evaluation · Truthy and falsy values · The ternary operator ? : · The switch statement · Testing boundary values1 LeetCode problem to practise18 min
  4. Lesson 04The for LoopThe most important idea in this series. Start, condition and update, traced step by step with a dry-run table until the pattern is clear.Topics · Why loops exist · The three parts: start, check, update · The exact order of execution · Counting up, down and in steps · How many times a loop runs · The accumulator pattern: sum, product, count · Flags, break and continue · Off-by-one errors and how to avoid them3 LeetCode problems to practise22 min
  5. Lesson 05The while LoopRepeat while a condition is true. Taking a number apart digit by digit, and a clear rule for choosing between for and while.Topics · while syntax and the order of execution · The digit loop: n % 10 and Math.floor(n / 10) · Building a number digit by digit (reverse) · Infinite loops and how to avoid them · do … while · Choosing between for and while4 LeetCode problems to practise18 min
  6. Lesson 06Nested Loops and PatternsA loop inside a loop is a grid: rows outside, columns inside. Built up with star and number patterns until you can draw any shape.Topics · The grid model: rows and columns · Building a row, then printing it · Inner limits that depend on the outer variable · A three-question recipe for any pattern · Triangles, pyramids and hollow shapes · Counting pairs, and how much work nested loops do2 LeetCode problems to practise20 min
  7. Lesson 07FunctionsPackage a piece of logic, give it inputs and get a result back. The difference between return and console.log, and why every interview answer is a function.Topics · Defining and calling functions · Parameters, arguments and default values · return vs console.log · Scope: variables inside stay inside · Early return · Arrow functions · Passing values vs passing references · Helper functions and the LeetCode answer format3 LeetCode problems to practise18 min
  8. Lesson 08ArraysMany values in one variable, numbered from 0. Reading, updating, looping and the first real interview questions on arrays.Topics · Indexes, length, reading and updating · Looping: index loop and for…of · push, pop, shift and unshift · Four core patterns: accumulate, best so far, count, search · Linear search · References and copying arrays · Built-in methods: includes, indexOf, slice, splice, sort, map, filter, reduce · Edge cases: empty, one element, duplicates4 LeetCode problems to practise24 min
  9. Lesson 09StringsText behaves like an array of characters that cannot be changed in place. Looping over characters, reversing, palindromes and counting.Topics · Indexing and length · Immutability: building new strings · Looping over characters · Character checks and character codes · Common methods: toLowerCase, trim, includes, indexOf, slice, split, join · Two pointers on a string · Edge cases: empty strings, case, spaces4 LeetCode problems to practise20 min
  10. Lesson 10Objects, Map and SetLook values up by name instead of by position. The counting pattern behind a large share of interview questions.Topics · Objects: records with named fields · Map: set, get, has, delete, size · The frequency-map pattern · Set: add, has and uniqueness · Why lookups are fast · Arrays of objects · Choosing between array, object, Map and Set5 LeetCode problems to practise20 min

Part 2 · Thinking Like a Problem-Solver

Reading a problem, Big-O, basic maths, your first recursion and counting with a hash map.

  1. Lesson 11How to Read a ProblemInput, output, constraints, examples and edge cases — and solving it by hand before writing any code.Topics · Inputs, outputs and constraints · Working through the examples by hand · Listing edge cases · Brute force first, then improve · A step-by-step method for every problem · Explaining your thinking out loud5 LeetCode problems to practise20 min
  2. Lesson 12Big-O: Counting the StepsHow many times does the loop run? Reading time and space complexity from code, and from the constraints of a problem.Topics · Why we count steps, not seconds · O(1), O(n), O(n²), O(log n), O(n log n) · Dropping constants and smaller terms · Space complexity · Best, average and worst case · Reading the constraints to choose an approach4 LeetCode problems to practise24 min
  3. Lesson 13Basic Maths for DSADigits, divisors, primes, the sieve, GCD and LCM, and fast powers.Topics · Digit problems revisited · All divisors in √n steps · Prime check and the Sieve of Eratosthenes · GCD and LCM with Euclid · Remainders and modular arithmetic · Fast exponentiation7 LeetCode problems to practise26 min
  4. Lesson 14Recursion BasicsA function that calls itself, a base case that stops it, and the call stack underneath.Topics · Base case and recursive case · The call stack during recursion · Printing 1 to N and N to 1 · Sum and factorial · Recursion on arrays and strings · Multiple recursive calls: Fibonacci · Stack overflow and recursion vs loops3 LeetCode problems to practise24 min
  5. Lesson 15Basic HashingCounting with arrays and maps, how a hash table works inside, and why lookup becomes instant.Topics · Counting with an array (fixed range, 26 letters) · Counting with a Map (any values) · Answering frequency queries · Highest and lowest frequency · How a hash table works: hash function, buckets, collisions6 LeetCode problems to practise24 min

Part 4 · Arrays and the First Patterns

Prefix sums, two pointers, sliding windows, Kadane's algorithm and matrices.

  1. Lesson 19Array Traversal ProblemsLargest and second largest, rotating, moving zeros, missing numbers and more — the problems every array round starts with.Topics · Largest and second largest · Checking if an array is sorted · Removing duplicates in place · Rotating by k (the reversal method) · Moving zeros · Missing number and single number · Union and intersection of sorted arrays7 LeetCode problems to practise22 min
  2. Lesson 20Prefix SumPre-compute running totals so that any range sum is instant.Topics · Running sums · Range sum queries · Pivot index · Prefix and suffix products · Subarray sum equals k (prefix sum + Map)7 LeetCode problems to practise24 min
  3. Lesson 21Two PointersTwo indices moving towards each other or in the same direction — pair sums, reversing, removing duplicates, 3Sum.Topics · Pointers from both ends · Pair sum in a sorted array · Same-direction pointers (read and write) · 3Sum · Container with most water · Three-way partition (Dutch national flag)8 LeetCode problems to practise26 min
  4. Lesson 22Sliding Window: Fixed SizeReuse the last window's work instead of recomputing it.Topics · From brute force to a sliding window · Maximum sum of k elements · Averages of every window · Counting with a window (vowels, matches)6 LeetCode problems to practise20 min
  5. Lesson 23Sliding Window: Variable SizeGrow and shrink a window to find the longest or shortest answer.Topics · The grow-and-shrink template · Longest window with a condition · Shortest window with a condition · “At most k” problems7 LeetCode problems to practise26 min
  6. Lesson 24Kadane's AlgorithmThe maximum subarray sum in a single pass, and the stock-trading problems built on the same idea.Topics · Maximum subarray: brute force to one pass · Returning the subarray itself · Best time to buy and sell stock · Maximum product subarray · Circular subarrays6 LeetCode problems to practise24 min
  7. Lesson 252-D Arrays and MatricesRows and columns: transpose, rotate, spiral order, set zeroes and search a matrix.Topics · Creating and looping over a matrix · Row and column sums · Transpose and rotate by 90° · Spiral order · Set matrix zeroes · Searching a sorted matrix7 LeetCode problems to practise26 min

Part 13 · Graphs

Storing graphs, BFS/DFS, topological sort, shortest paths, union-find.

  1. Lesson 49What a Graph IsVertices, edges and the adjacency list (each vertex's list of neighbours).Topics · Vertices and edges; directed and undirected; weighted · Adjacency list vs adjacency matrix · Building a graph from an edge list · Degree, paths and connected components · Grids as graphs2 LeetCode problems to practiseread
  2. Lesson 50Graph Traversal: BFS and DFSCount islands, flood fill, rotting oranges and copy a graph.Topics · BFS with a queue and a visited set · DFS, recursive and with a stack · Connected components · Grid traversal: islands and flood fill · Multi-source BFS · Cloning a graph5 LeetCode problems to practiseread
  3. Lesson 51Topological SortPut tasks in order when some depend on others, and find loops (cycles).Topics · Directed acyclic graphs · Kahn's algorithm (in-degree) · DFS-based ordering · Cycle detection in directed graphs · Course schedule2 LeetCode problems to practiseread
  4. Lesson 52Shortest PathsBFS when all steps cost the same, Dijkstra for other costs, and Bellman–Ford for limits.Topics · BFS for unweighted graphs · Dijkstra with a priority queue · Shortest paths on a grid · Bellman–Ford and limited stops4 LeetCode problems to practiseread
  5. Lesson 53Union-FindGroup things fast: connected groups, finding cycles and minimum spanning trees.Topics · Parent array and find · Path compression · Union by size or rank · Connected components and redundant edges · Kruskal's minimum spanning tree4 LeetCode problems to practiseread

Glossary

162 terms — dry run, accumulator, off-by-one, frequency map and the rest. Inside any lesson, hover or tap a dotted term to see its meaning without leaving the page. Browse all terms →

How this syllabus was built

The order of topics and the subtopics in every lesson were checked against the most widely used free resources for learning DSA and preparing for interviews. They are all worth bookmarking.

ResourceWhat it is best for
coding-interview-university (362k ★)A complete computer-science study plan; good for seeing the whole field.
javascript-algorithms (197k ★)Every standard data structure and algorithm written in JavaScript, with explanations.
Tech Interview Handbook (143k ★)Per-topic cheat sheets: techniques, edge cases and the essential questions. Also home of the Grind 75 list.
labuladong's algorithm notes (136k ★)Reusable templates for problem families such as sliding window and binary search.
Hello Algo (130k ★)A free, animated book for beginners; excellent pictures of every data structure.
NeetCode roadmapA pattern-by-pattern problem list (NeetCode 150) with a video solution for each problem.
Striver's A2Z DSA sheetA long, step-by-step problem sheet that starts from the absolute basics.
LeetCodeWhere you practise. Every lesson links the matching LeetCode problems.
VisuAlgoInteractive animations of sorting, trees, graphs and more.

GitHub star counts as of October 2026.