Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA
Problem: Minimum number of jumps to reach the last index of [2, 3, 1, 1, 4] when from index i you may jump up to a[i] steps forward. What is the minimum?
- A. 2
- B. 3
- C. 1
- D. 4
Correct answer: A. 2
Greedy BFS levels: each jump extends the reachable frontier, and you jump whenever you reach the end of the current frontier. Jumping to the furthest index from the start is not always optimal.
More Coding Interview Problems questions
- Problem: Find the k-th largest element of [3, 2, 1, 5, 6, 4] for k = 2 (1-indexed among values, with duplicates counted separately).
- Problem: The intervals [1,3], [2,4], [3,6], [7,8], [5,9], [8,10] are given. What is the minimum number of intervals to remove so that the…
- Problem: Find the number of unique triplets (as value sets) that sum to zero in [−1, 0, 1, 2, −1, −4].
- Problem: How many substrings of "eceba" contain exactly 2 distinct characters?
- Problem: For the array [3, 1, 4, 1, 5, 9, 2] and window size 3, compute the sum of the minimum of every contiguous window.
- Problem: The Euclidean algorithm is run on (1071, 462). How many division steps (a mod b operations) are performed until the remainder…