5. Arrays

Traversal, in-place updates, rotation and the top array interview questions.

Your progress0 of 14
7easy
6medium
1hard

Understand the topic

An array is a row of numbered lockers: you can open any locker instantly by its number (O(1)), but inserting into the middle means shifting everyone after it (O(n)).

Most array problems are won by one of these moves: a single pass with a running value (max, min, count), using the values themselves as indexes (marking or "cyclic sort"), reversing parts of the array, or writing from the back so you don't overwrite data you still need.

#ProblemPatternLevel
1 Build Array from Permutation #1920 Index mapping Easy LeetCode ↗
2 Max Consecutive Ones #485 Running counter Easy LeetCode ↗
3 Check if Array Is Sorted and Rotated #1752 Count drops Easy LeetCode ↗
4 Best Time to Buy and Sell Stock #121 Running minimum Easy LeetCode ↗
5 Find All Numbers Disappeared in an Array #448 Index marking Easy LeetCode ↗
6 Plus One #66 Carry handling Easy LeetCode ↗
7 Merge Sorted Array #88 Merge from the back Easy LeetCode ↗
8 Rotate Array #189 Reversal trick Medium LeetCode ↗
9 Next Permutation #31 Pivot + reverse Medium LeetCode ↗
10 Rearrange Array Elements by Sign #2149 Two write indexes Medium LeetCode ↗
11 Find All Duplicates in an Array #442 Index marking Medium LeetCode ↗
12 Find the Duplicate Number #287 Floyd's cycle on indexes Medium LeetCode ↗
13 H-Index #274 Counting sort Medium LeetCode ↗
14 First Missing Positive #41 Cyclic sort Hard LeetCode ↗

Work top to bottom — each list goes from easy to hard. Try a problem for at least 15 minutes before opening a hint. Ticks are saved in your browser.