Largest Combination With Bitwise AND Greater Than Zero LeetCode solution in Java
1class Solution {2public static int largestCombination(int[] candidates) {3int arr[] = new int[32];4for (int i = 0; i < candidates.length; i++) {5String temp = Integer.toBinaryString(candidates[i]);6int n = temp.length();7int index = 0;8while (n-- > 0) {9arr[index++] += temp.charAt(n) - '0';10}11}12int res = Integer.MIN_VALUE;13for (int i = 0; i < 32; i++) {14res = Math.max(res, arr[i]);15}16return res;17}18}