---
# System prepended metadata

title: 2275. Largest Combination With Bitwise AND Greater Than Zero
tags: [Leetcode, Bit Manipulation, Medium]

---

# 2275. Largest Combination With Bitwise AND Greater Than Zero
###### tags: `Leetcode` `Medium` `Bit Manipulation`
## 思路
用cnt记录每个bit 1出现的次数 取最大的即可
## Code
```java=
class Solution {
    public int largestCombination(int[] candidates) {
        int[] cnt = new int[32];
        int max = 0;
        for(int candidate:candidates){
            for(int i=0; i<32; i++){
                int num = 1<<i;
                if((candidate&num)>0) cnt[i]++;
                max = Math.max(cnt[i], max);
            }
        }
        return max;
    }
}
```