Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4dba055

Browse files
committedAug 28, 2022
Runtime: 102 ms (Top 22.47%) | Memory: 41.5 MB (Top 88.20%)
1 parent bbceaf3 commit 4dba055

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 102 ms (Top 22.47%) | Memory: 41.5 MB (Top 88.20%)
12
/**
23
* @param {number} n
34
* @param {number} k
@@ -7,14 +8,12 @@ var kthGrammar = function(n, k) {
78
if (n == 1 && k == 1) {
89
return 0;
910
}
10-
11+
1112
const mid = Math.pow(2, n-1) / 2;
12-
13+
1314
if (k <= mid) {
1415
return kthGrammar(n-1, k);
1516
} else {
1617
return kthGrammar(n-1, k-mid) == 1 ? 0 : 1;
1718
}
1819
};
19-
20-

0 commit comments

Comments
 (0)
Please sign in to comment.