Data Structures & AlgorithmsModerateTCS NQT · Product Company SDE

Problem: Starting at index 0 of the array [2, 4, 1, 6, 3], repeatedly jump forward by the value at the current index (no wraparound; the process stops when the jump leaves the array). How many distinct indices are visited including index 0?

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

Correct answer: B. 3

Follow the forward jumps until one leaves the array or revisits an index. The visited list gives the count, which includes index 0 itself.

More Coding Interview Problems questions

Exams that ask this topic