0283 move zeroes - #5
Conversation
| ```python | ||
| class Solution: | ||
| def moveZeroes(self, nums: list[int]) -> None: | ||
| end_of_nonzeroes = 0 |
There was a problem hiding this comment.
この変数は、実際には「次にゼロ以外を置くべき位置」を表しているので、next_non_zero_indexなどが命名として良さそうだと思いました
There was a problem hiding this comment.
そうですね、名前は悩みました。
たしかにnext_non_zero_indexのほうがわかりやすいかと思います!
| @@ -0,0 +1,69 @@ | |||
| # 387. First Unique Character in a String | |||
There was a problem hiding this comment.
1 つの PR に含める回答は、問題 1 つ分にすることをお勧めいたします。 2 つ以上の問題が 1 つの PR に含まれていると、レビューの対象が分散し、レビューの品質が下がる可能性があります。
There was a problem hiding this comment.
ブランチの切り方を間違えたためかと思われますので、以後注意いたします。
|
|
||
| class Solution2: | ||
| def firstUniqChar(self, s: str) -> int: | ||
| seen_index:dict[str, int] = {} |
There was a problem hiding this comment.
: のあとにスペースを空けるものと空けないものとが混ざっているのが気になりました。空けるほうに統一することをお勧めいたします。
| ```python | ||
| class Solution: | ||
| def firstUniqChar(self, s: str) -> int: | ||
| appearences: dict[str, int] = {} |
There was a problem hiding this comment.
dict の変数名には、キーと値がそれぞれどのようなものを表すかが分かる名前を付けると良いと思います。また、しばしば (キー)_to_(値) という書式が使われるように思います。 char_to_count はいかがでしょうか?
There was a problem hiding this comment.
dict の変数名には、キーと値がそれぞれどのようなものを表すかが分かる名前を付けると良い
以後意識いたします。
https://leetcode.com/problems/move-zeroes/description