Skip to content

Commit 236397b

Browse files
authored
Update 779-k-th-symbol-in-grammar.js
1 parent 7365ceb commit 236397b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

779-k-th-symbol-in-grammar.js

+14
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,17 @@ const kthGrammar = function(N, K) {
88
if (K % 2 === 0) return (kthGrammar(N - 1, K / 2) === 0) ? 1 : 0;
99
else return (kthGrammar(N - 1, (K + 1) / 2) === 0) ? 0 : 1;
1010
};
11+
12+
/**
13+
14+
// think of the problem like this
15+
/* 0
16+
/ \
17+
0 1
18+
/ \ / \
19+
0 1 1 0
20+
/ \ / \ / \ / \
21+
0 1 1 0 1 0 0 1
22+
*/
23+
24+
*/

0 commit comments

Comments
 (0)