https://leetcode.com/problems/longest-substring-without-repeating-characters/submissions/
from functools import cmp_to_key
def cmp(s1: str, s2: str) -> int:
return -1 if len(s1) > len(s2) else 1
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
substr = [""] * len(s) # substr[i] : s[i]에서 시작했을 때 최대 substring의 길이
start = 0
end = 0
while end < len(s):
if s[end] in substr[start]:
start += 1
end = start
else:
substr[start] += s[end]
end += 1
substr = sorted(substr, key=cmp_to_key(cmp))
return 0 if not substr else len(substr[0])