Skip to content

Commit 1ec1a95

Browse files
committed
rotate_image
1 parent 550587f commit 1ec1a95

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,5 @@ Golang solution for leetcode. For each problem, there is a simple *_test.go to t
4242
#### [43. multiply strings](https://github.com/hitzzc/go-leetcode/tree/master/multiply_strings)
4343
#### [46. permutations](https://github.com/hitzzc/go-leetcode/tree/master/permutations)
4444
#### [47. permutations II](https://github.com/hitzzc/go-leetcode/tree/master/permutations_II)
45+
#### [48. rotate image](https://github.com/hitzzc/go-leetcode/tree/master/rotate_image)
4546

rotate_image/rotate_image.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package rotate_image
2+
3+
import (
4+
"fmt"
5+
)
6+
7+
func rotate(matrix [][]int) {
8+
n := len(matrix) - 1
9+
for i := 0; i < n/2+1; i++ {
10+
for j := 0; j < len(matrix)/2; j++ {
11+
matrix[j][n-i], matrix[n-i][n-j], matrix[n-j][i], matrix[i][j] = matrix[i][j], matrix[j][n-i], matrix[n-i][n-j], matrix[n-j][i]
12+
}
13+
}
14+
return
15+
}

0 commit comments

Comments
 (0)