48. Rotate Image Golang inplace solution 3 lines


  • 0
    N
    func rotate(m [][]int)  {
        N := len(m)
        for i := 0; i < (N) / 2; i ++ {
            for j := 0; j < (N+1)/2 ; j++{
                 m[j][N-i-1], m[N-i-1][N-j-1],m[N-j-1][i],m[i][j] = m[i][j],m[j][N-i-1],m[N-i-1][N-j-1],m[N-j-1][i]  
            }
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.