Conversation
hayashi-ay
left a comment
There was a problem hiding this comment.
step2と同じコードでも良いのでstep3も提出して貰えると良いと思います。
|
|
||
| 5m | ||
|
|
||
| sorted(s)で返るのはlistじゃないことに注意 |
There was a problem hiding this comment.
ドキュメントにも目を通すと良いと思います。
Return a new sorted list from the items in iterable.
| 5m | ||
|
|
||
| sorted(s)で返るのはlistじゃないことに注意 | ||
| .values()で返るのもlistじゃなくてdict_valuesという定義されたオブジェクト? |
There was a problem hiding this comment.
ドキュメントにも目を通すと良いと思います。
Return a new view of the dictionary’s values.
| from collections import defaultdict | ||
| class Solution: | ||
| def groupAnagrams(self, strs: List[str]) -> List[List[str]]: | ||
| sorted_str_to_strs = defaultdict(list) |
There was a problem hiding this comment.
なんか変数名が微妙な気がします。うーん、sorted_str_to_originalとかはどうでしょうか?
There was a problem hiding this comment.
これ微妙ですよね~
ただ、個人的にはsorted_str_to_originalもあまりピンとこないんですよね... (私がoriginalに意味を見出しすぎているのかもしれないです)
sorted_str_to_anagramsだとどうなんでしょう?
|
レビューしていただいてありがとうございます!
こちら、理由をお伺いしてもよろしいでしょうか? |
いやあ、そんな深い理由はないですが、step3をやっていないのか、step3をやった上でstep2と同じコードになったのかというのが気になるくらいですかね。 |
|
なるほど~ 今回は5mで解けちゃったのでstep3を省略しました。 |
|
個人的には最初の方はstep3を省略しないほうが良いとは思うのですが、お任せします。個人的な体験談としてはstep3はやっておいた方が良いかなと思いますが。 https://hayapenguin.com/notes/Posts/2024/04/24/how-to-practice-coding-effectively
|
|
まあ、私もこんな勝手なこと言ってましたね。 |
|
step3が特に重要なのは感じていつつ、まだ若干軽視していた節があるかもしれないです。 |
問題:https://leetcode.com/problems/group-anagrams/description
https://github.com/fhiyo/leetcode/pull/15/files
これ、groupbyとか使った新しい書き方をしていて参考