diff --git a/longest-substring-without-repeating-characters.py b/longest-substring-without-repeating-characters.py index 4c4ab87..12bc245 100644 --- a/longest-substring-without-repeating-characters.py +++ b/longest-substring-without-repeating-characters.py @@ -4,8 +4,8 @@ # longest substring without repeating characters def solution(s: str) -> int: - if len(s) == 0: - return 0 + if len(s) <= 1: + return len(s) longest = -1 @@ -21,7 +21,6 @@ def solution(s: str) -> int: for t in range(f+1, len(s)): cs = count(s[f:t+1]) longest = cs if cs > longest else longest - longest = 1 if longest < 1 else longest return longest