Last active
January 20, 2021 07:27
-
-
Save mumunuu/fa5f36d55649f129ddf38d734f06735a to your computer and use it in GitHub Desktop.
algorithm(leetcode) Rotate Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func rotate(matrix [][]int) { | |
matrixLength := len(matrix) | |
for i := 0; i < matrixLength; i++ { | |
for j := i; j < matrixLength; j++ { | |
tmp := matrix[j][i] | |
matrix[j][i] = matrix[i][j] | |
matrix[i][j] = tmp | |
} | |
} | |
for i := 0; i < matrixLength; i++ { | |
for j := 0; j < matrixLength/2; j++ { | |
tmp := matrix[i][j] | |
matrix[i][j] = matrix[i][matrixLength-j-1] | |
matrix[i][matrixLength-j-1] = tmp | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment