Skip to content

Commit 6306891

Browse files
authored
Create 2275-largest-combination-with-bitwise-and-greater-than-zero.js
1 parent 196758f commit 6306891

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} candidates
3+
* @return {number}
4+
*/
5+
const largestCombination = function(candidates) {
6+
let res = 0
7+
for(let i = 0; i < 25; i++) {
8+
let tmp = 0, bit = 1 << i
9+
for(const e of candidates) {
10+
if((e & bit) !== 0) tmp++
11+
}
12+
res = Math.max(res, tmp)
13+
}
14+
return res
15+
};

0 commit comments

Comments
 (0)