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?

  1. A. 2
  2. B. 3
  3. C. 1
  4. 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

Exams that ask this topic