某知名网站的讨论,
For example, given a MxN (3x4) two dimensional array
1, 2, 3, 4
5, 6, 7, 8
9,10,11,12
You need to rearrange it into:
9 , 5, 1,
10, 6, 2,
11, 7, 3,
12, 8, 4
Write a function to do it in-place.
e.g. M=3, N=4, and a memory block contains:
[1,2,3,4,5,6,7,8,9,10,11,12]
You need to change the memory block into
[9,5,1,10,6,2,11,7,3,12,8,4]
"In-place" means memory constaint is O(1).