-
Notifications
You must be signed in to change notification settings - Fork 0
Group Anagrams.md #11
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
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.
良いと思います。dictのkeyはtupleでも良いかもしれないですね。
ありがとうございます!ちなみに使い分けのtipsとかあったりしますか? |
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://docs.python.org/3/library/stdtypes.html#str | ||
- やりたいのは`"".join(['a', 'e', 't'])` | ||
- https://docs.python.org/3/library/stdtypes.html#str.join |
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.
Tuple を使うほうが気分がいい時もあるとは思います。表せている集合の範囲が素直かということかなと思います。
こういうところの速度は Python はそもそも C++ の50倍前後遅いのであまり気にしないかなと思います。
下は、"*" を区切り字としている例です。
https://discord.com/channels/1084280443945353267/1303605021597761649/1306562757315002389
|
||
- 入力文字列の個数をn、最大の文字列長をmとして | ||
- 時間計算量: O(n * mlogm)。 | ||
- 空間計算量: O(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.
O(n * m)だと思います。
https://leetcode.com/problems/group-anagrams/description/