TATA ELXSI Hiring | On Campus OA (2022) | Rotate Image (Matrix Rotation by 90 Degrees Clockwise In Place)

Question · Posted Jun 2026

Problem Statement You are given an n × n matrix representing an image. Rotate the image by 90 degrees clockwise without using any additional 2D matrix. The rotation must be performed in-place, meaning you must modify the original matrix directly. Example 1 Input matrix = [  [1,2,3],  [4,5,6],  [7,8,9] ] Output [  [7,4,1],  [8,5,2],  [9,6,3] ] Explanation Original Matrix: 1 2 3 4 5 6 7 8 9 After 90° Clockwise Rotation: 7 4 1 8 5 2 9 6 ...

The full answer & interview discussion are available to premium members.

Log in Create a free account