Skip to content

Commit a8e57d7

Browse files
committed
Runtime: 450 ms (Top 11.11%) | Memory: 53.8 MB (Top 66.67%)
1 parent e3cd8e8 commit a8e57d7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1+
// Runtime: 450 ms (Top 11.11%) | Memory: 53.8 MB (Top 66.67%)
12
var sumSubseqWidths = function(nums) {
23
const mod = 1000000007;
34
nums.sort((a, b) => a - b), total = 0, power = 1;
45
for(let i = 0; i < nums.length; i++) {
56
total = (total + nums[i] * power) % mod;
67
power = (power * 2) % mod;
78
}
8-
9+
910
power = 1;
1011
for(let i = nums.length - 1; i >= 0; i--) {
1112
total = (total - nums[i] * power + mod) % mod;
1213
power = (power * 2) % mod;
1314
}
14-
15+
1516
return (total + mod) % mod
16-
};
17+
};

0 commit comments

Comments
 (0)