Skip to content

First Unique Character in a String#9

Merged
Exzrgs merged 1 commit intomainfrom
arai60-first-unique-character-in-a-string
May 28, 2024
Merged

First Unique Character in a String#9
Exzrgs merged 1 commit intomainfrom
arai60-first-unique-character-in-a-string

Conversation

Copy link
Copy Markdown

@kzmkt kzmkt left a comment

Choose a reason for hiding this comment

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

シンプルでいいと思います。
元の引数名が悪いので仕方がないですが、s → text, c → character とかくらいが見やすいかもですね。

聞かれてもおかしくないのは「defaultdict使わずにかけますか?」くらいですかね?
enemurateまでは冗長なだけなので、同じこと聞かれる気はあまりしないです。

@Exzrgs Exzrgs merged commit cb2ee6e into main May 28, 2024
for i, c in enumerate(s):
if char_count[c] == 1:
return i
return -1
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 がどのような意味を持つのかコードを見るだけだと分からないので、定数にして役割に準じた名前をつけたり、コードコメントを残すといったことをした方がいいように思いました。

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