Data Structures & AlgorithmsModerateFlipkart/Uber OA · placement

The array [1, 2, 3, 4, 5, 6, 7, 8] is rotated RIGHT by 3 positions and then LEFT by 2 positions. What is the final array?

  1. A. [3, 4, 5, 6, 7, 8, 1, 2]
  2. B. [6, 7, 8, 1, 2, 3, 4, 5]
  3. C. [2, 3, 4, 5, 6, 7, 8, 1]
  4. D. [8, 1, 2, 3, 4, 5, 6, 7]

Correct answer: D. [8, 1, 2, 3, 4, 5, 6, 7]

The net effect is a left rotation by (2 − 3) mod 8 = 7, so the array starts at element 8: [8, 1, 2, 3, 4, 5, 6, 7].

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

Exams that ask this topic