Skip to content

Commit b46f2b4

Browse files
committed
Runtime: 509 ms (Top 12.12%) | Memory: 43.2 MB (Top 78.79%)
1 parent c22a253 commit b46f2b4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1+
// Runtime: 509 ms (Top 12.12%) | Memory: 43.2 MB (Top 78.79%)
12
/**
23
* @param {number[]} nums
34
* @return {number}
45
*/
56
var countMaxOrSubsets = function(nums) {
6-
7+
78
let n = nums.length;
89
let len = Math.pow(2, n);
910
let ans = 0;
1011
let hash = {};
11-
12-
for (let i = 0; i < len; i++) {
12+
13+
for (let i = 0; i < len; i++) {
1314
let tmp = 0;
14-
for (let j = 0; j < n; j++) {
15+
for (let j = 0; j < n; j++) {
1516
if(i & (1 << j)) {
1617
tmp |= nums[j];
1718
}
@@ -23,6 +24,6 @@ var countMaxOrSubsets = function(nums) {
2324
}
2425
ans = Math.max(ans, tmp);
2526
}
26-
27+
2728
return hash[ans];
28-
};
29+
};

0 commit comments

Comments
 (0)