Created
September 17, 2019 22:43
-
-
Save DataSolveProblems/566c6426baf07e992f8c15229a47469b to your computer and use it in GitHub Desktop.
This file contains hidden or 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: str) -> int: | |
mapper = {} | |
start = 0 | |
longest = 0 | |
for i, c in enumerate(s): | |
if c in mapper and mapper[c] >= start: | |
start = mapper[c] + 1 | |
else: | |
longest = max(longest, i - start + 1) | |
mapper[c] = i | |
return longest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment