class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if not s:
return 0
uq = set(s)
uq_length = len(uq)
windows = s[0]
left = 0
right = 1
max_len = 1
for i in range(1, len(s)):
flag_index = windows.find(s[i])
if flag_index == -1:
windows += s[i]
right += 1
else:
left = flag_index + 1
right += 1
windows = windows[left:] + s[i]
if max_len < len(windows):
max_len = len(windows)
return max_len