We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 640f36e commit 0b40134Copy full SHA for 0b40134
0934-bitwise-ors-of-subarrays/0934-bitwise-ors-of-subarrays.java
@@ -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