From 766faa48506296abec252989eb0d1cdd2555c1b9 Mon Sep 17 00:00:00 2001 From: Yigid BALABAN Date: Wed, 11 Sep 2024 19:02:26 +0300 Subject: [PATCH] continuous imprv. --- longest-substring-without-repeating-characters.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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