Offer to prove safety questions surface 48. longest substring no repeating characters (sliding window)

Title Description

Please find a longest common string does not contain repeating characters from a string, we calculate the length of the longest substring.
Here Insert Picture Description

Thinking

See link

Code

class Solution:
	def lengthOfLongestSubstring(self,s):
		result = 0
		low = 0
		for high in range(len(s)):
			if s[high] not in s[low:high]:
				result = max(high-low+1,result)
			else:
				while s[high] in s[low:high]:
					low += 1
		return result
He published 198 original articles · won praise 566 · views 20000 +

Guess you like

Origin blog.csdn.net/weixin_37763870/article/details/105355529