You are viewing a single comment's thread. Return to all comments →
Python solution.... It involves doing OR operation on 2 values and finding number of ones so that we can get maximum number of ones
def acmTeam(topic): max_sum = 0 count = 0 for i in range(0, len(topic)-1): for j in range(i+1, len(topic)): sum = bin(int(("0b"+topic[i]), 2) | int(("0b"+topic[j]), 2)) if list(sum).count('1') > max_sum: max_sum = list(sum).count('1') count = 1 continue if max_sum == list(sum).count('1'): count+=1 return max_sum, count
Seems like cookies are disabled on this browser, please enable them to open this website
ACM ICPC Team
You are viewing a single comment's thread. Return to all comments →
Python solution.... It involves doing OR operation on 2 values and finding number of ones so that we can get maximum number of ones