Data Structures & AlgorithmsHardGATE CS · competitive programming

An n×n matrix is rotated 90° clockwise. The original is [[1,2,3],[4,5,6],[7,8,9]]. Which value is now in the top-left corner?

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

Correct answer: C. 7

A clockwise rotation sends (i, j) to (j, n−1−i), so the new top-left comes from the bottom-left corner, 7. A counter-clockwise rotation would give 3.

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

Exams that ask this topic