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

Arrays

Start with the most fundamental data structure — why it exists and how to use it — then solve the 16 array questions interviews ask most.

  • 12 Lessons
  • 16 Problems
  • 73 Illustrations
  • 45 Slides

Dry-run engine

Two Sum II (Sorted Array)

See memory mutations as they happen in CPU cache lines.

O(1) Memory
Input
nums = [2, 3, 5, 9, 11, 15], target = 14
Output · Returns
Press play to run it
How it works

If arr[L] + arr[R] > target, shift right pointer leftward (R--). Otherwise, increment left pointer (L++).

contiguous_ram_buffer[6]

  • Left (L)0 (val: 2)
  • Right (R)5 (val: 15)
  • Current Sum17 (> 14)

L=0 (val 2), R=5 (val 15). Sum is 17. Since 17 > 14 (target), decrement Right pointer (R = 4).

1 / 3

What you will learn

  • Why arrays exist, and what their contiguous memory layout makes cheap and expensive
  • How to create, read, update and loop over arrays in JavaScript, Python, Java and C++
  • When an array is the right tool, and how a problem's constraints point to the approach
  • The 16 most asked array interview questions, from Two Sum to Merge Intervals
  • A repeatable method for every problem: brute force, then optimal, then the best solution
  • Dry-running every best solution step by step with an interactive simulator, on your own input

Why this course

Arrays are the first data structure everyone learns and the one interviews lean on most. This course is written to be read from top to bottom: whether you are writing your first loop or brushing up for interviews, every idea is introduced before it is used.

It starts with why arrays exist and how they sit in memory, then how to use them in real code, then when they are the right tool.

From there you solve the 16 most asked array interview questions. Every problem is solved the way you should solve it in an interview: first the brute force, then an optimal improvement, then the best solution. Each one comes with a picture of the key idea, code in four languages, the complexity of every approach, and a simulator you can dry-run with your own input.

Requirements

  • Comfort writing loops, conditionals, and functions in at least one language
  • No prior data structures experience — every term is introduced before it is used
  • No prior big-O knowledge — complexity is built up from counting operations
  • A willingness to attempt each problem before revealing its solution

Course Contents