Skip to content

Commit 5a3795b

Browse files
authored
Create Largest Combination With Bitwise AND Greater Than Zero.java
1 parent 1c1f3cf commit 5a3795b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public int largestCombination(int[] candidates) {
3+
int[] bitCount = new int[24];
4+
for (int i = 0; i < 24; i++) {
5+
for (int candidate : candidates) {
6+
if ((candidate & (1 << i)) != 0) {
7+
bitCount[i]++;
8+
}
9+
}
10+
}
11+
int result = 0;
12+
for (int count : bitCount) {
13+
result = Math.max(count, result);
14+
}
15+
return result;
16+
}
17+
}

0 commit comments

Comments
 (0)