Skip to content

Commit 8f3fd2f

Browse files
committed
Runtime: 117 ms (Top 41.38%) | Memory: 44.1 MB (Top 58.62%)
1 parent 80319f5 commit 8f3fd2f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 117 ms (Top 41.38%) | Memory: 44.1 MB (Top 58.62%)
12
/**
23
* @param {string} s
34
* @param {number} k
@@ -9,18 +10,16 @@ var longestSubsequence = function(s, k) {
910
let j = s.length - 1; // starting from the last digit
1011
let i = 0; // binary number position
1112
let acc = 0;
12-
13+
1314
while(j >= 0){
1415
let positionNumber = Number(s[j]) * Math.pow(2, i);
1516
j--;
1617
i++;
1718
if(acc + positionNumber > k) continue;
1819

19-
acc += positionNumber;
20-
count++;
20+
acc += positionNumber;
21+
count++;
2122
}
2223

2324
return count;
2425
};
25-
26-

0 commit comments

Comments
 (0)