📌  相关文章
📜  将矩阵顺时针旋转 90 度 javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:49.302000             🧑  作者: Mango

代码示例1
// transpone
const transpose = matrix => {
  for (let row = 0; row < matrix.length; row++) {
    for (let column = 0; column < row; column++) {
      let temp = matrix[row][column]
      matrix[row][column] = matrix[column][row]
      matrix[column][row] = temp
    }
  }
  return matrix;
}
// reverse 
const reverse = matrix =>  matrix.map(row => row.reverse());
// rotate
const rotate = matrix => transpose(reverse(matrix));