Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Starting at index 0 of [1, 2, 1, 1, 1], each a[i] is the maximum forward jump. What is the minimum number of jumps needed to reach the last index?

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

Correct answer: D. 3

The minimum jumps follow the BFS layers of the reachable range. The jumps 0 to 1, then 1 to 3, then 3 to 4 reach the end in 3 jumps.

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

Exams that ask this topic