832. 翻转图像

 

 

 

 

 

 

 1 class Solution(object):
 2     def flipAndInvertImage(self, A):
 3         """
 4         :type A: List[List[int]]
 5         :rtype: List[List[int]]
 6         """
 7         for i in range(len(A)):
 8             temp = A[i][::-1]
 9             for j in range(len(temp)):
10                 temp[j] = 0 if temp[j] == 1 else 1
11             A[i] = temp
12         return A
13 
14 if __name__ == '__main__':
15     solution = Solution()
16     print(solution.flipAndInvertImage([[1, 1, 0], [1, 0, 1], [0, 0, 0]]))

 

posted @ 2020-04-29 09:47  人间烟火地三鲜  阅读(143)  评论(0)    收藏  举报