mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-10 13:37:33 +08:00
添加 18 题
This commit is contained in:
13
leetcode/0832.Flipping-an-Image/832. Flipping an Image.go
Normal file
13
leetcode/0832.Flipping-an-Image/832. Flipping an Image.go
Normal file
@ -0,0 +1,13 @@
|
||||
package leetcode
|
||||
|
||||
func flipAndInvertImage(A [][]int) [][]int {
|
||||
for i := 0; i < len(A); i++ {
|
||||
for a, b := 0, len(A[i])-1; a < b; a, b = a+1, b-1 {
|
||||
A[i][a], A[i][b] = A[i][b], A[i][a]
|
||||
}
|
||||
for a := 0; a < len(A[i]); a++ {
|
||||
A[i][a] = (A[i][a] + 1) % 2
|
||||
}
|
||||
}
|
||||
return A
|
||||
}
|
Reference in New Issue
Block a user