Skip to content

Instantly share code, notes, and snippets.

@wushbin
Created April 1, 2020 04:45
Show Gist options
  • Select an option

  • Save wushbin/3f5d2fc3525550b93ea901aabe272d5a to your computer and use it in GitHub Desktop.

Select an option

Save wushbin/3f5d2fc3525550b93ea901aabe272d5a to your computer and use it in GitHub Desktop.
class Solution {
public int subarrayBitwiseORs(int[] A) {
Set<Integer> result = new HashSet<>();
Set<Integer> current = new HashSet<>();
for (int num : A) {
Set<Integer> temp = new HashSet<>();
temp.add(num);
for (int pre : current) {
temp.add(num | pre);
}
result.addAll(temp);
current = temp;
}
return result.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment