Skip to content

Commit d0c1a2a

Browse files
committed
feat: 만족스럽지 않은 첫 시도
1 parent e06a675 commit d0c1a2a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

  • longest-substring-without-repeating-characters
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def lengthOfLongestSubstring(self, s: str) -> int:
3+
longest_substring: str = ""
4+
current_substring: str = ""
5+
6+
for c in s:
7+
if len(longest_substring) < len(current_substring):
8+
longest_substring = current_substring
9+
10+
if c not in set(current_substring):
11+
current_substring += c
12+
13+
else:
14+
current_substring = current_substring.split(c)[1] + c
15+
16+
if len(longest_substring) < len(current_substring):
17+
longest_substring = current_substring
18+
return len(longest_substring)
19+
20+
21+
if __name__ == "__main__":
22+
s = Solution()
23+
print(s.lengthOfLongestSubstring("a"))

0 commit comments

Comments
 (0)