Medium
Remove All Ones With Row and Column Flips — Python
Full explanation · Time O(m * n) · Space O(1)
# Time: O(m * n)
# Space: O(1)
class Solution(object):
def removeOnes(self, grid):
"""
:type grid: List[List[int]]
:rtype: bool
"""
return all(grid[i] == grid[0] or all(grid[i][j] != grid[0][j] for j in xrange(len(grid[0]))) for i in xrange(1, len(grid)))