See More

link: https://leetcode.com/problems/rotate-image/ class Solution { public void rotate(int[][] matrix) { int n=matrix.length; for(int layer=0; layer top matrix[layer][i] = matrix[last-offset][first]; //bottom -> left matrix[last-offset][first] = matrix[last][last-offset]; //right -> bottom matrix[last][last-offset] = matrix[i][last]; //top -> right matrix[i][last] = top; } } } }