Skip to content

Instantly share code, notes, and snippets.

@mylons
Created March 3, 2019 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mylons/ba6c059ac9a15218f27f803ec3e015b1 to your computer and use it in GitHub Desktop.
Save mylons/ba6c059ac9a15218f27f803ec3e015b1 to your computer and use it in GitHub Desktop.
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