-
Notifications
You must be signed in to change notification settings - Fork 0
779. K-th Symbol in Grammer #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
https://leetcode.com/problems/k-th-symbol-in-grammar/description/ We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10. For example, for n = 3, the 1st row is 0, the 2nd row is 01, and the 3rd row is 0110. Given two integer n and k, return the kth (1-indexed) symbol in the nth row of a table of n rows.
|
良さそうに思います! |
|
良いと思います |
hayashi-ay
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
良いと思います。
| https://stackoverflow.com/questions/109023/count-the-number-of-set-bits-in-a-32-bit-integer | ||
|
|
||
| - x86というプロセッサなら命令がそのままあるらしい | ||
| - それ使わないやつが非常に面白い。(偶数bit + 奇数bit)によって先頭から2桁ずつbitcountして結果を2桁ずつに収める、先頭から4桁ずつbitcountして結果を4桁ずつに収める、を順に行う(説明が下手) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.oreilly.co.jp//books/9784873112886/mobile.html
「Binary Hacks ─ ハッカー秘伝のテクニック100選」薦めておきます。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary Hacksには、ビット演算ネタはほとんどなさそうでしょうか…
新しいのがもうすぐ出るみたいですね
https://www.amazon.co.jp/Binary-Hacks-Rebooted-%E2%80%94%E4%BD%8E%E3%83%AC%E3%82%A4%E3%83%A4%E3%81%AE%E4%B8%96%E7%95%8C%E3%82%92%E6%8E%A2%E6%A4%9C%E3%81%99%E3%82%8B%E3%83%86%E3%82%AF%E3%83%8B%E3%83%83%E3%82%AF89%E9%81%B8-%E6%B2%B3%E7%94%B0/dp/4814400853
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
そうでした。すみません、混ざってました。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
どちらも面白そうですね、ありがとうございます
https://leetcode.com/problems/k-th-symbol-in-grammar/description/ We build a table of n rows (1-indexed). We start by writing 0 in the 1st row. Now in every subsequent row, we look at the previous row and replace each occurrence of 0 with 01, and each occurrence of 1 with 10.
For example, for n = 3, the 1st row is 0, the 2nd row is 01, and the 3rd row is 0110. Given two integer n and k, return the kth (1-indexed) symbol in the nth row of a table of n rows.