Proud to say, my solution is better than, leetcode's official solution😇
@darshankumar55462 күн бұрын
English Explanation: kzbin.info/www/bejne/gZvJlnZuopmrb7c
@darshankumar55462 күн бұрын
# SOLUTION better than leetcode's official solution: class Solution: def maxEqualRowsAfterFlips(self, matrix: List[List[int]]) -> int: m=len(matrix) n=len(matrix[0]) nums=[] for num in matrix: l=len(num) val=0 for i in range(l): val+=(num[i])*(2**(l-i-1)) nums.append(val) print(nums) visited=set() eligible=set([0,(2**(n))-1]) MaxAns=0 for i in range(m): if(i in visited): continue ans=1 for j in range(i+1,m): if(j in visited): continue if((nums[i]^nums[j]) in eligible): ans+=1 visited.add(j) MaxAns=max(MaxAns,ans) visited.add(i) print(f"{ans} nos has same BITpattern as that of:{nums[i]}") return MaxAns # [ # [0,0,0], # [0,0,1], # [1,1,0] # ] # [0,0,1] # -->[0,0,1] # -->[1,1,0] # xor result shld be: # [0,0,0] or [1,1,1] # decimal: 0 or 7 (2**3 -1)