Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 452 Bytes

1072.md

File metadata and controls

16 lines (14 loc) · 452 Bytes

1072. Flip Columns For Maximum Number of Equal Rows

Solution 1 (time O(mn), space O(m))

class Solution(object):
    def maxEqualRowsAfterFlips(self, matrix):
        """
        :type matrix: List[List[int]]
        :rtype: int
        """
        cnt = collections.Counter()
        for row in matrix:
            cnt[tuple(row) if row[0] == 0 else tuple(x ^ 1 for x in row)] += 1
        return max(cnt.values())