- Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if len(s)==0:
return 0
max_out=1
i,j=0,1
while j<len(s):
for index in range(i,j):
if s[j]==s[index]:
i=index+1
max_out=max(max_out,j-i+1)
j=j+1
return max_out
网友评论