2275. Largest Combination With Bitwise AND Greater Than Zero (&1, >>= 1 )

T: O(n*32)
class Solution {
    public int largestCombination(int[] candidates) {
        int[] bitCount = new int[32];
        for (int num : candidates) {
            int i = 0;
            while (num > 0) {
                int isOne = num & 1;
                num >>= 1;
                bitCount[i++] += isOne;
            }
        }
        int result = 0;
        for (int c : bitCount) {
            result = Math.max(result, c);
        }
        return result;
    }
}

/**
421 
001
101
011

how to make result > 0, the larget number of the bit is 1 at the same position! T: O(n*32)
  10000
  10001
1000111
 111110
   1100
  11000
   1110


 */

Last updated