Skip to content

Commit 0b40134

Browse files
Time: 170 ms (82.38%), Space: 71.2 MB (83.61%) - LeetHub
1 parent 640f36e commit 0b40134

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int subarrayBitwiseORs(int[] arr) {
3+
Set<Integer> result = new HashSet<>();
4+
5+
for(int i = 0; i < arr.length; i++){
6+
result.add(arr[i]);
7+
8+
for(int j = i - 1; j >= 0; j--){
9+
if(arr[j] == (arr[j] | arr[i])) break;
10+
11+
arr[j] |= arr[i];
12+
result.add(arr[j]);
13+
}
14+
}
15+
16+
return result.size();
17+
}
18+
}

0 commit comments

Comments
 (0)