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.
- 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).
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
2. Using arrays in code
3. Solving problems with arrays
4. Most asked interview questions
- Two Sumcode
solutionEasy - Move Zeroescode
solutionEasy - Best Time to Buy and Sell Stockcode
solutionEasy - Majority Elementcode
solutionEasy - Sort 0s, 1s and 2scode
solutionMedium - Maximum Subarray Sumcode
solutionMedium - Rotate Arraycode
solutionMedium - Product of Array Except Selfcode
solutionMedium - Find All Duplicates in an Arraycode
solutionMedium - Find Peak Elementcode
solutionMedium - Container With Most Watercode
solutionMedium - 3Sumcode
solutionMedium - Subarray Sum Equals Kcode
solutionMedium - Increasing Triplet Subsequencecode
solutionMedium - Kth Largest Element in an Arraycode
solutionMedium - Merge Intervalscode
solutionMedium
Related courses
- StringsCharacter arrays with their own set of classic patterns — two pointers, sliding window, and more.19 lessons · 19 problems
- Hash MapKey → value lookups in O(1) on average — the tool behind counting, “seen it before?” checks, prefix sums and sliding windows.4 lessons · 11 problems
- StackLast-in, first-out — the structure behind call stacks, undo history, and expression parsing.6 lessons · 13 problems
