Esc
  • Loading…
↑ ↓ to moveEnter to openEsc to close

Linked List

Learn what a linked list really is — boxes joined by arrows — then solve the 12 linked list questions interviews ask most.

  • 4 Lessons
  • 12 Problems
  • 51 Illustrations

Dry-run engine

Reverse a Linked List

Nodes are scattered across the heap and held together only by the addresses in their next fields.

O(1) Memory
Input · List
head = 10 → 20 → 30 → 40
Output · New head
Press play to run it
How it works

Save next = curr.next, point curr.next back at prev, then advance both: prev = curr, curr = next.

heap_nodes[4] · non-contiguous

  • prevnull
  • curr0x7a10 (10)
  • Last pointer write—

Four nodes sit at scattered heap addresses, chained only by the address stored in each next field. Start with prev = null and curr = head (0x7a10).

1 / 6

What you will learn

  • What a linked list is, and how nodes and next pointers sit in memory
  • Why linked lists exist, and what they do better and worse than arrays
  • When to reach for a linked list, and when an array is the better choice
  • How to create, traverse, insert into and delete from a list in four languages
  • The 12 most asked linked list interview questions, from reversal to cycle detection
  • Brute force, optimal and best solutions for every problem, with a dry-run simulator

Why this course

Linked lists are where pointer thinking starts. Most mistakes in linked list problems aren't about algorithms at all — they're a lost next pointer, a missing null check, or a head that should have moved. This course is built to make those mistakes visible.

It starts with what a linked list is, why it exists, when to use one and how to use one in real code — every idea drawn as boxes and arrows, with a simulator for the basic operations.

Then you solve the 12 most asked linked list interview questions. Every problem is solved the interview way: first the brute force, then an optimal improvement, then the best solution, each with code in four languages, its time and space cost, and a simulator that shows every pointer move.

Requirements

  • Comfort writing loops, conditionals and functions in at least one language
  • The Arrays course, or equivalent familiarity with indexes and two pointers
  • No prior pointer experience — references are introduced from scratch

Course Contents