Skip to content

Conversation

@SuperHotDogCat
Copy link
Owner

def kthGrammar(self, n: int, k: int) -> int:
moves = deque([]) # 0: move left 1: move right
# store the order from the leaf
for i in range(n-1):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i使っていないので、for _ in range(n - 1)でいい気がします。

@@ -0,0 +1,20 @@
class Solution:
def kthGrammar(self, n: int, k: int) -> int:
moves = deque([]) # 0: move left 1: move right
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k を 1-indexed から 0-indexed に変換してから処理すると、コードが少しシンプルになると思いました。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants