Data Structures & AlgorithmsHardTCS NQT · Accenture

Reverse the sublist between positions 3 and 6 (1-based, inclusive) of the list 1, 2, 3, 4, 5, 6, 7, 8. What value is at position 4 of the result?

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

Correct answer: C. 5

Reversing positions 3 to 6 gives 1, 2, 6, 5, 4, 3, 7, 8, so position 4 holds 5. Reversing the wrong span shifts the answer.

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

Exams that ask this topic