Data Structures & AlgorithmsHardGATE CS · TCS NQT

A robot starts at position 0 on a number line. For each move it steps right (R) or left (L). Count the number of distinct positions visited, including the start, for the moves RRLLRRRLLLL.

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

Correct answer: D. 5

Mark every position reached, including the starting point, and count the distinct marks. Positions revisited during back-and-forth moves are counted once.

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

Exams that ask this topic