-
Notifications
You must be signed in to change notification settings - Fork 0
22. Generate Parentheses #58
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
| closeはopen以下でないと追加できない | ||
| closeの数 > openの数にはならない | ||
|
|
||
| memo.cppを実装(nittocoさんの回答を参照) |
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.
変わり種だと、
開き+閉じ*(0~ここまでの開きの数までのどれか)までを一つの仕事とみるという仕事の分担方法もあるように思います。
という方法も考えました。
https://discord.com/channels/1084280443945353267/1218823830743547914/1231546400714788864
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://github.com/nittoco/leetcode/pull/43/commits/e373af0cefa8ca2b5b73a4fb901666bd0880c8bd | ||
|
|
||
|
|
||
| ・カタラン数という言葉を初めて聞いた |
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://github.com/frinfo702/software-engineering-association/pull/10 | ||
|
|
||
| >時間計算量: O(n * 2^(2n)) (文字列の任意の位置で開き括弧/閉じ括弧が許される仮定の甘い見積もり。厳密には n x カタラン数でO(4^n/(sqrt(n)))? (ref: https://en.wikipedia.org/wiki/Catalan_number)) | ||
| カタラン数:C_n = (2n)!/(n + 1)!n! これが4^n / n^(3/2)sqrt(pi)でオーダーを用いるので省略されて最終的にO(4^n / sqrt(n))になるのか |
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/generate-parentheses/description/
問題文(プレミアムの場合)
備考
次に解く問題の予告
フォルダ構成
LeetCodeの問題ごとにフォルダを作成します。
フォルダ内は、step1.cpp、step2.cpp、step3.cpp、memo.cppとmemo.mdとなります。
memo.md内に各ステップで感じたことを追記します。