Math
1 | class Solution { |
Remarks:
Be carefull of the index: we start from
nums[0][0]but notnums[1][1]!How blocks rotate:
nums[i][j] -> nums[j][n - j - 1].TC: $O(n^2)$, SC: $O(1)$
No need to process the center point (when
nis odd).
1 | class Solution { |
Remarks:
Be carefull of the index: we start from nums[0][0] but not nums[1][1]!
How blocks rotate: nums[i][j] -> nums[j][n - j - 1].
TC: $O(n^2)$, SC: $O(1)$
No need to process the center point (when n is odd).