Skip to content

Commit f8ac345

Browse files
authored
Create 2275. Largest Combination With Bitwise AND Greater Than Zero
1 parent 8584454 commit f8ac345

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public:
3+
int largestCombination(vector<int>& c) {
4+
vector<int> v(32,0);
5+
for(auto it : c){
6+
for(int i = 31; i>=0; i--){
7+
int k = it >> i;
8+
if(k & 1) v[i]++;
9+
}
10+
}
11+
int ans = 0;
12+
for(int i = 0; i<32; i++){
13+
ans = max(ans,v[i]);
14+
}
15+
16+
return ans;
17+
}
18+
};

0 commit comments

Comments
 (0)