Skip to content

Create 3. Longest Substring Without Repeating Characters.md#48

Open
tokuhirat wants to merge 1 commit intomainfrom
3.-Longest-Substring-Without-Repeating-Characters
Open

Create 3. Longest Substring Without Repeating Characters.md#48
tokuhirat wants to merge 1 commit intomainfrom
3.-Longest-Substring-Without-Repeating-Characters

Conversation

@tokuhirat
Copy link
Owner

Copy link

@huyfififi huyfififi left a comment

Choose a reason for hiding this comment

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

👍

letters_in_window.remove(s[left])
left += 1
letters_in_window.add(s[right])
longest_length =max(longest_length, right - left + 1)

Choose a reason for hiding this comment

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

nit: =の後に一つスペースを開けるのが一般的かと思います。

longest_length = 0

end_index = 0
characters = collections.defaultdict(int)

Choose a reason for hiding this comment

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

step 1の解答にコメントを残すのは無粋かもしれませんが、このdefaultdictで文字とそのカウントが対応していることを読み取るのに少し時間がかかりました。既に意識されていることと思いますが、char_to_countにするか、0か1のフラグを保持していることを伝えられるといいな、と思いました。

Copy link
Owner Author

Choose a reason for hiding this comment

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

そちらの方がわかりやすいですね。コメントありがとうございます。

return longest_length
```

2分,2分,1分で3回Accept

Choose a reason for hiding this comment

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

いいと思います。
letters_in_windowいいですね

def lengthOfLongestSubstring(self, s: str) -> int:
longest_length = 0
left = 0
letters_in_window = set()

Choose a reason for hiding this comment

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

いい変数名ですね。

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.

4 participants