Rotate Image
ID: 48
Last updated
ID: 48
Last updated
You are given an n x n
2D matrix
representing an image, rotate the image by 90 degrees (clockwise).
You have to rotate the image , which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
For a odd size matrix (3x3), only first two row and first one column should be considered, other indexes can be calculated based on these info.
For a even size matrix(4x4), first two row and first two column should be considered.
So, i in range(0, (n+1)/2), j in range(0. n/2)