leetcode-832翻转图像
翻转图像
思路:
先对图像进行水平翻转,然后反转图片(对每个像素进行异或操作)
代码:
class Solution: def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]: a = [a[::-1] for a in A] for i in range(len(a)): for j in range(len(a[i])): a[i][j] = a[i][j] ^ 1 return a