Skip to content

Conversation

@Fuminiton
Copy link
Owner

def kthGrammar(self, n: int, k: int) -> int:
if n == 1:
return 0
half_nums = 2 ** (n - 2)
Copy link

Choose a reason for hiding this comment

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

half_indexとかのほうが意味に合ってそうな気がします。

def kthGrammar(self, n: int, k: int) -> int:
if n == 1:
return 0
half_nums = 1 << (n - 2)
Copy link

Choose a reason for hiding this comment

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

こちらの書き方で leftshift した方が ** を使うより速いですね

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