Skip to content

387. First Unique Character in a String#14

Open
hiro111208 wants to merge 1 commit into
mainfrom
387-first-unique-character-in-a-string
Open

387. First Unique Character in a String#14
hiro111208 wants to merge 1 commit into
mainfrom
387-first-unique-character-in-a-string

Conversation

@hiro111208
Copy link
Copy Markdown
Owner

Comment thread step1.md
chars.add(char)
unique_char_to_idx[char] = idx

if len(unique_char_to_idx) == 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.

辞書の空判定は、

if not unique_char_to_idx:

とするのが良いかもしれません。

参考: https://google.github.io/styleguide/pyguide.html#2144-decision

Comment thread step1.md
chars = set()
unique_char_to_idx = dict()

for idx, char in enumerate(s):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

こちらのコメントをご参照ください。
hemispherium/LeetCode_Arai60#10 (comment)

Comment thread step1.md
chars = set()
unique_char_to_idx = dict()

for idx, char in enumerate(s):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

char は他の言語で予約語となっているため、避けたほうが無難かもしれません。 c・ch あたりが良いと思います。

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