2128. Remove All Ones With Row and Column Flips

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2128

class Solution:
    def removeOnes(self, grid: List[List[int]]) -> bool:
        s = set()
        for row in grid:
            t = tuple(row) if row[0] == grid[0][0] else tuple(x ^ 1 for x in row)
            s.add(t)
        return len(s) == 1