-
-
Notifications
You must be signed in to change notification settings - Fork 300
/
898.py
24 lines (22 loc) · 851 Bytes
/
898.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
__________________________________________________________________________________________________
sample 796 ms submission
class Solution:
def subarrayBitwiseORs(self, A: List[int]) -> int:
Set = set()
tmp = {0}
for cur in A:
tmp = {cur | ele for ele in tmp}
tmp.add(cur)
Set.update(tmp)
return len(Set)
__________________________________________________________________________________________________
sample 39212 kb submission
class Solution:
def subarrayBitwiseORs(self, A: List[int]) -> int:
ans = set()
cur = {0}
for x in A:
cur = {x | y for y in cur} | {x}
ans |= cur
return len(ans)
__________________________________________________________________________________________________