Problem statement

https://binarysearch.com/problems/Flip-and-Invert-Matrix/

Solution

Equal to Leetcode 0832. Flipping an Image.

Complexity

It is O(mn) for time and space.

Code

class Solution:
    def solve(self, A):
        return [[1^q for q in row[::-1]] for row in A]