LeetCode题解-3
题目:
Longest Substring Without Repeating Characters
解答:
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
longest = 0
length = len(s)
for k in range(length):
st = set()
long = 0
for kk in range(k, length):
if s[kk] in st:
break
else:
st.add(s[kk])
long += 1
if long > longest:
longest = long
return longest