2044. Count Number of Maximum Bitwise-OR Subsets
On This Page
class Solution:
def countMaxOrSubsets(self, nums: List[int]) -> int:
n = len(nums)
res = 0
mx = 0
for mask in range(1 << n):
t = 0
for i, v in enumerate(nums):
if (mask >> i) & 1:
t |= v
if mx < t:
mx = t
res = 1
elif mx == t:
res += 1
return res