Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: A cyclic array [1, 2, 3, 4, 5] is rotated so that the element at index 0 becomes the element at index 2 (rotate left by 2). What is the sum of the elements at indices 0 and 4 after this rotation?

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

Correct answer: A. 5

After rotating left by two, the array is 3, 4, 5, 1, 2, so indices 0 and 4 hold 3 and 2, summing to 5.

More Coding Interview Problems questions

Exams that ask this topic