**338. 比特位计数(动态规划+位运算)**

方法三:动态规划——最低有效位

class Solution {
    public int[] countBits(int n) {
        int[] bits = new int[n+1];
        for(int i = 1; i <= n; i++) {
            bits[i] = bits[i >> 1] + (i & 1);
        }
        return bits;
    }
}

**136. 只出现一次的数字(异或运算)**

class Solution {
    public int singleNumber(int[] nums) {
        int res = 0;
        for(int x: nums) {
            res = res ^ x;
        }
        return res;
    }
}

**1318. 或运算的最小翻转次数(按照思路来即可,注意是或运算)**

class Solution {
    public int minFlips(int a, int b, int c) {
        int res = 0;
        while((long)a + b + c > 0) {
            int la = a & 1;
            int lb = b & 1;
            int lc = c & 1;
            a = a >> 1;
            b = b >> 1;
            c = c >> 1;
            if(lc == 0) {
                res = res + la + lb;
            }else {
                if(la + lb >= 1) continue;
                else res++;
            }
        }
        return res;
    }
}