Leetcode 934 Solution

This article provides solution to leetcode question 934 (bitwise-ors-of-subarrays)

https://leetcode.com/problems/bitwise-ors-of-subarrays

Solution

class Solution:
    def subarrayBitwiseORs(self, A):
        dp = set()
        ans = set()
        for a in A:
            new_dp = set([a])
            for x in dp:
                new_dp.add(a | x)
            dp = new_dp
            ans |= dp
        return len(ans)