Thursday, August 21, 2014

Rotate Image

Problem

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

Rotate the image by 90 degrees (clockwise).

Follow up:
Could you do this in-place?

Idea

The idea is to swap the matrix twice. Check here for how to swap.

Solution

No comments:

Post a Comment