Courses
Amazon Coding Interview
Amazon's greatest hits: hashing, two pointers, grids, and binary search on the answer.
- Islands
- 10
- Lessons
- 90
- Exercises
- 311
Complete codeDebugCode orderMultiple choiceTapTrace
Island 1Ship packages in the given order within D days — each day loads consecutive packages up to the boat's capacity. Find the smallest capacity that ships them all in time.
- Decode the Problem3 exercises, 5 min
- Approach Check4 exercises, 5 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 5 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 6 min
- Test and Analyze3 exercises, 5 min
- Boss BattleBoss8 exercises, 8 min
Island 2Given a grid of land ('1') and water ('0') cells, count the islands — regions of land connected horizontally or vertically.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 3Find the two numbers in an array that add up to a target, and return their indices.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 4Bars of varying heights trap rain between them — compute how much water the whole skyline holds.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 5Given prerequisite pairs, decide whether every course can be finished — or whether the requirements loop forever.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze4 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 6Rot spreads from bad oranges to neighbors each minute — find how long until no fresh orange remains, or prove some never rot.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 7Find every unique triplet in an array that sums to zero — without listing the same triplet twice.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 8Pick the slowest banana-eating speed that still finishes every pile before the guards return in h hours.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 9Two sorted arrays, one combined median — find it without actually merging them.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min
Island 10You may repaint at most k letters — find the longest stretch you can turn into one repeated character.
- Decode the Problem3 exercises, 4 min
- Approach Check4 exercises, 4 min
- Build the Brute Force3 exercises, 5 min
- Find the Bottleneck2 exercises, 4 min
- Discover the Optimal Approach3 exercises, 4 min
- Assemble the Algorithm2 exercises, 5 min
- Read the Implementation3 exercises, 5 min
- Test and Analyze3 exercises, 4 min
- Boss BattleBoss8 exercises, 8 min