1. var rotate = function(matrix) {
    2. const n = matrix.length;
    3. for (let i = 0; i < Math.floor(n / 2); ++i) {
    4. for (let j = 0; j < Math.floor((n + 1) / 2); ++j) {
    5. const temp = matrix[i][j];
    6. matrix[i][j] = matrix[n - j - 1][i];
    7. matrix[n - j - 1][i] = matrix[n - i - 1][n - j - 1];
    8. matrix[n - i - 1][n - j - 1] = matrix[j][n - i - 1];
    9. matrix[j][n - i - 1] = temp;
    10. }
    11. }
    12. };
    13. 作者:LeetCode-Solution
    14. 链接:https://leetcode.cn/problems/rotate-image/solution/xuan-zhuan-tu-xiang-by-leetcode-solution-vu3m/
    15. 来源:力扣(LeetCode
    16. 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。