Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
func rotate(matrix [][]int) {
reverse(matrix)
swap(matrix)
}
func reverse(matrix [][]int){
for i , j := 0, len(matrix)-1; i < j; i, j = i+1, j-1{
matrix[i], matrix[j] = matrix[j], matrix[i]
}
}
func swap(matrix [][]int){
for i := 0; i < len(matrix); i++ {
for j := i; j < len(matrix); j++ {
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.