Created
March 3, 2019 16:25
-
-
Save mylons/ba6c059ac9a15218f27f803ec3e015b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Solution: | |
def lengthOfLongestSubstring(self, s): | |
""" | |
:type s: str | |
:rtype: int | |
""" | |
if len(s) < 2: return len(s) | |
subs = [] | |
for x in range(0, len(s)): | |
sub = set() | |
for y in range(x, len(s)): | |
c = s[y] | |
if c in sub: | |
break | |
else: | |
sub.add(c) | |
subs.append(''.join(sub)) | |
return max(len(sub) for sub in subs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment