Leetcode 3. Longest Substring Without Repeating Characters
Hint: use "Slicing Window"
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) == 0:
return 0
substring = ""
maxLen = 0
for i in range(len(s)):
if s[i] in substring:
substring = substring[substring.index(s[i])+1:]
substring += s[i]
if maxLen < len(substring):
maxLen = len(substring)
return maxLen