Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 779 Bytes

832.-flipping-an-image.md

File metadata and controls

36 lines (28 loc) · 779 Bytes

832. Flipping an Image

{% tabs %} {% tab title="自己太蠢版本" %}

 def flipAndInvertImage(self, A):
        return [[1 ^ i for i in reversed(row)] for row in A]

{% endtab %}

{% tab title="Python" %}

class Solution:
    def flipAndInvertImage(self, A: List[List[int]]) -> List[List[int]]:
        
        ## 本能
        if not A: return 
        
        for i in range(len(A)):
            A[i] = A[i][::-1]
            
        for i in range(len(A)):
            ans = []
            for j in range(len(A[i])):
                if A[i][j] == 1:
                    ans.append(0)
                else:
                    ans.append(1)
                    
            A[i] = ans
            
        return A

{% endtab %} {% endtabs %}