Skip to content

Longest Substring Without Repeating Characters#2

Merged
Exzrgs merged 3 commits intomainfrom
arai60-longest-substring-without-repeating-characters
May 15, 2024
Merged

Longest Substring Without Repeating Characters#2
Exzrgs merged 3 commits intomainfrom
arai60-longest-substring-without-repeating-characters

Conversation

@Exzrgs
Copy link
Copy Markdown
Owner

@Exzrgs Exzrgs commented Apr 27, 2024

Copy link
Copy Markdown

@liquo-rice liquo-rice left a comment

Choose a reason for hiding this comment

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

良さそうです。

class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
char_to_index = dict()
answer = 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.

max_lengthの方が分かりやすいかもしれないです。

Comment on lines +19 to +20
answer = max(answer, i-start_index)
start_index = seen.get(s[i])+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.

(単純に忘れただけだと思いますが)+-の両脇にスペースを入れた方が良いと思います。

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