Level 1 · Foundations
Free Arrays lessons
35 lessons, about 295 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.
Stage 0What an array is
Stage 1Traversal
Stage 2Traversal with state
Stage 5Two pointers
Stage 6Arrays and hashing
- Remember where you first saw itKeep the first position of every value in a map.8 min
- Remember the latest positionKeep the last position of every value to spot close repeats.8 min
- Only start at the startFind the longest run of consecutive values with a set.10 min
- Ask the set in orderFind the smallest positive number that isn't in the list.7 min
Stage 7Prefix sums
- Pay once, answer fastBuild running totals once, then answer any range sum with one subtraction.9 min
- Left side, right sideUse the total and a running sum to compare both sides of every position.8 min
- Same total twiceSpot a stretch that sums to zero by remembering every running total.9 min
- Count stretches that hit kCount every run of numbers that adds up to k, with a map of running totals.10 min
Stage 8Sliding window
- Slide, don't re-addMove a fixed-size window one step at a time, adding one number and dropping one.8 min
- Judge every windowSlide a fixed window and count the ones that pass a test.8 min
- Grow, then shrinkA window that stretches on the right and tightens on the left.10 min
- Keep the window validFind the longest window that breaks a rule at most k times.10 min
Stage 9Kadane’s algorithm
- Extend or start freshFind the largest sum of any run, deciding at each number whether to keep the run going.10 min
- Flip the questionThe same walk finds the smallest sum, with max turned into min.6 min
- Around the cornerThe best run in a circle is either an ordinary run, or everything except the worst run.10 min
- Cheapest so farFind the best buy-then-sell profit by remembering the lowest price seen.8 min
Stage 10Mastery
There’s more after this
These are the opening stages of Arrays. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.
Start the full path free