Largest Combination With Bitwise AND Greater Than Zero LeetCode solution in Java

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

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0