Leetcode 1147 Solution
This article provides solution to leetcode question 1147 (flip-columns-for-maximum-number-of-equal-rows)
Access this page by simply typing in "lcs 1147" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/flip-columns-for-maximum-number-of-equal-rows
Solution
class Solution:
def maxEqualRowsAfterFlips(self, matrix: List[List[int]]) -> int:
m = collections.defaultdict(int)
ans = 0
for row in matrix:
s = "".join([str(cell ^ row[0]) for cell in row])
m[s] += 1
ans = max(ans, m[s])
return ans