Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Starting at index 0 of [3, 2, 1, 0, 4], each value a[i] allows a jump of at most a[i] steps forward. Can the last index be reached?

  1. A. yes
  2. B. only with a second start
  3. C. cannot be determined
  4. D. no

Correct answer: D. no

The farthest reachable index from 0, 1 or 2 is 3, and index 4 lies beyond it, so the last index cannot be reached.

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

Exams that ask this topic