Data Structures & AlgorithmsModerateTCS NQT · Accenture

Problem: The array [1, 2, 3, 4, 5, 6, 7, 8] is rotated left by 3 and then the first 4 elements are reversed. What is the element at index 0 of the result?

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

Correct answer: D. 7

Left rotation by 3 gives [4,5,6,7,8,1,2,3], and reversing the first four puts 7 in front. Rotating right gives 1, skipping the reversal gives 4, and reversing the whole array gives 3.

More Coding Interview Problems questions

Exams that ask this topic