Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Autosaved

...

Code Block
func rotate(matrix [][]int)  {
    n := len(matrix)
    for i := 0; i < n; i++ {
        for j := 0; j < n-i-1; j++ {
            matrix[i][j], matrix[n-j-1][n-i-1] = matrix[n-j-1][n-i-1], matrix[i][j]
        }
    }

    for i := 0; i < n; i++ {
        slices.Reverse(matrix[i])
    }
}

LC 54. Spiral Matrix 螺旋矩阵

https://leetcode.com/problems/spiral-matrix/description/

Code Block