898. 子数组按位或操作

  分析:

  

class Solution {
    public int subarrayBitwiseORs(int[] A) {
        Set<Integer> set = new HashSet<>();
        Set<Integer> cur = new HashSet<>();
        for(int num : A) {
            Set<Integer> cur1 = new HashSet<>();
            cur1.add(num);
            for(int k : cur) {
                cur1.add(num | k);
            }
            cur = cur1;
            set.addAll(cur);
        }
        return set.size();
    }
}

 

posted @ 2020-08-20 15:47  Sexyomaru  阅读(124)  评论(0编辑  收藏  举报