Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

matrix =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Rotate 90° clockwise = transpose + reverse each row.

Approach

  • Transpose in-place: swap (i,j) with (j,i) for j>i.
  • Reverse every row.

Why it works

Transpose turns columns into rows; reversing rows completes the clockwise rotation.

Code
Loading...
Complexity
Time: O(n^2)
Space: O(1)
Solution
Updated: 2026-02-23

Idea

Rotate 90° clockwise = transpose + reverse each row.

Approach

  • Transpose in-place: swap (i,j) with (j,i) for j>i.
  • Reverse every row.

Why it works

Transpose turns columns into rows; reversing rows completes the clockwise rotation.

Code
Loading...
Complexity
Time: O(n^2)
Space: O(1)