The solution that is working for me for this problem (https://leetcode.com/problems/flipping-an-image/) here is
class Solution:
def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:
return [[bit ^ 1 for bit in reversed(row)] for row in image]
However , and I feel like I dont understand something about list comprehension here, the following gives me an error:
class Solution:
def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:
return [[bit ^ 1] for bit in reversed(row) for row in image]
Why am i getting this error ?, and similarly this does not work either.
class Solution:
def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:
return [bit ^ 1 for bit in reversed(row) for row in image]