MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / Solution

Class Solution

DP/BitwiseORsOfSubarray.py:69–86  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67
68"""
69class Solution(object):
70 def subarrayBitwiseORs(self, A):
71 """
72 :type A: List[int]
73 :rtype: int
74 """
75 if not A:
76 return 0
77
78 dp = [{A[0]}]
79
80 for i in range(1, len(A)):
81 new = {A[i]}
82 for j in dp[i-1]:
83 new.add(j|A[i])
84 dp.append(new)
85
86 return len(set.union(*dp))
87

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected