Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

A jump game on [2, 3, 0, 1, 4, 0, 2, 1, 3] starts at index 0; from index i you may jump 1 to a[i] steps forward. What is the minimum number of jumps needed to reach the last index?

  1. A. 4
  2. B. 5
  3. C. 3
  4. D. 2

Correct answer: C. 3

Level-by-level BFS: indices 1 and 2 are reachable in one jump, index 4 in two, and index 8 (the last) in three, while no two-jump path reaches index 8.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic