标签:eve AC style color matrix length ace 图像 用例
1 /** 2 * @param {number[][]} matrix 3 * @return {void} Do not return anything, modify matrix in-place instead. 4 */ 5 var rotate = function(matrix) { 6 let i = 0, 7 j = matrix.length - 1, 8 rowIndex = 0, 9 colIndex = matrix.length - 1, 10 exchange = 0; 11 while (i < matrix.length - 1 && j >= 0) { 12 exchange = matrix[i][rowIndex]; 13 matrix[i][rowIndex] = matrix[j][colIndex]; 14 matrix[j][colIndex] = exchange; 15 rowIndex++; 16 j--; 17 18 if (rowIndex == colIndex) { 19 i++; 20 rowIndex = 0; 21 j = matrix.length - 1; 22 colIndex--; 23 } 24 } 25 matrix.reverse() 26 };
测试21个用例 ,用时68ms
标签:eve AC style color matrix length ace 图像 用例
原文地址:https://www.cnblogs.com/syfnx/p/9067101.html