logo
Interview
    Interview Guide
    Coding Problems List
Sponsored: Coursera
Problems

Rotate Image

Problem

You are given an n x n 2D matrix representing an image.

Rotate the image by 90 degrees (clockwise).

Example

Given a matrix

[
    [1,2],
    [3,4]
]

rotate it by 90 degrees (clockwise), return

[
    [3,1],
    [4,2]
]

Challenge

Could you do this in-place?

Online Judge