Skip to content

Commit

Permalink
Create main.java
Browse files Browse the repository at this point in the history
  • Loading branch information
Alisherka7 authored Nov 7, 2024
1 parent c5b0702 commit e9d8110
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {

public int largestCombination(int[] candidates) {
int maxCount = 0; // Variable to track the maximum count of set bits.
for (int i = 0; i < 24; i++) {
int count = 0; // Count of numbers with the i-th bit set.
for (int num : candidates) {
if ((num & (1 << i)) != 0) { // Check if the i-th bit is set.
count++;
}
}
maxCount = Math.max(maxCount, count); // Update the maximum count.
}
return maxCount;
}
}

0 comments on commit e9d8110

Please sign in to comment.