Leetcode 861 Solution

This article provides solution to leetcode question 861 (flipping-an-image)

https://leetcode.com/problems/flipping-an-image

Solution

class Solution(object):
    def flipAndInvertImage(self, A):
        """
        :type A: List[List[int]]
        :rtype: List[List[int]]
        """
        for i, row in enumerate(A):
            A[i] = reversed(row)

        for i, row in enumerate(A):
            A[i] = [1 - val for val in A[i]]

        return A