Skip to content

0283 move zeroes - #5

Open
tsadamor wants to merge 2 commits into
mainfrom
0283-move-zeroes
Open

0283 move zeroes#5
tsadamor wants to merge 2 commits into
mainfrom
0283-move-zeroes

Conversation

@tsadamor

Copy link
Copy Markdown
Owner

Tomoki Sadamori added 2 commits July 18, 2026 14:47
Comment thread 0283-move-zero/memo.md
```python
class Solution:
def moveZeroes(self, nums: list[int]) -> None:
end_of_nonzeroes = 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この変数は、実際には「次にゼロ以外を置くべき位置」を表しているので、next_non_zero_indexなどが命名として良さそうだと思いました

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうですね、名前は悩みました。
たしかにnext_non_zero_indexのほうがわかりやすいかと思います!

@@ -0,0 +1,69 @@
# 387. First Unique Character in a String

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 つの PR に含める回答は、問題 1 つ分にすることをお勧めいたします。 2 つ以上の問題が 1 つの PR に含まれていると、レビューの対象が分散し、レビューの品質が下がる可能性があります。

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ブランチの切り方を間違えたためかと思われますので、以後注意いたします。


class Solution2:
def firstUniqChar(self, s: str) -> int:
seen_index:dict[str, int] = {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

: のあとにスペースを空けるものと空けないものとが混ざっているのが気になりました。空けるほうに統一することをお勧めいたします。

```python
class Solution:
def firstUniqChar(self, s: str) -> int:
appearences: dict[str, int] = {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict の変数名には、キーと値がそれぞれどのようなものを表すかが分かる名前を付けると良いと思います。また、しばしば (キー)_to_(値) という書式が使われるように思います。 char_to_count はいかがでしょうか?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dict の変数名には、キーと値がそれぞれどのようなものを表すかが分かる名前を付けると良い

以後意識いたします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants