Skip to content

Commit ef8eb3d

Browse files
committed
feat: add typescript solution to lc problem: No.2275
No.2275.Largest Combination With Bitwise AND Greater Than Zero
1 parent 9d4d63b commit ef8eb3d

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

solution/2200-2299/2275.Largest Combination With Bitwise AND Greater Than Zero/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,18 @@ class Solution {
9898
### **TypeScript**
9999

100100
```ts
101-
101+
function largestCombination(candidates: number[]): number {
102+
const n = 24;
103+
let ans = 0;
104+
for (let i = 0; i < n; i++) {
105+
let count = 0;
106+
for (let num of candidates) {
107+
if (num >> i & 1) count++;
108+
}
109+
ans = Math.max(ans, count);
110+
}
111+
return ans;
112+
};
102113
```
103114

104115
### **...**

solution/2200-2299/2275.Largest Combination With Bitwise AND Greater Than Zero/README_EN.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ class Solution {
8484
### **TypeScript**
8585

8686
```ts
87-
87+
function largestCombination(candidates: number[]): number {
88+
const n = 24;
89+
let ans = 0;
90+
for (let i = 0; i < n; i++) {
91+
let count = 0;
92+
for (let num of candidates) {
93+
if (num >> i & 1) count++;
94+
}
95+
ans = Math.max(ans, count);
96+
}
97+
return ans;
98+
};
8899
```
89100

90101
### **...**
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
function largestCombination(candidates: number[]): number {
2+
const n = 24;
3+
let ans = 0;
4+
for (let i = 0; i < n; i++) {
5+
let count = 0;
6+
for (let num of candidates) {
7+
if (num >> i & 1) count++;
8+
}
9+
ans = Math.max(ans, count);
10+
}
11+
return ans;
12+
};

0 commit comments

Comments
 (0)