Title Description:
Given a string, find the length of the oldest string that does not contain repeating characters. Example: given "ABCABCBB", the oldest string without repeating characters is "abc", then the length is 3. given "bbbbb", the longest substring is "B" and the length is 1. given "Pwwkew", the oldest string is "Wke" and the length is 3. Note that the answer must be a substring, "Pwke" is a subsequence rather than a substring
ideas:
Assuming the string is 0, return 0
Traversing a string, first judging whether the character is in the string TC, not, adding, and recording the length of the string
If in, add the character to the string TC and intercept from the place where the character occurred
ClassSolution:deflengthoflongestsubstring (self, s): M=0 TC=str () forCinchS:ifC not inchTC:TC+=C M=Max (LEN (TC), M)Else: TC+=C TC=tc[tc.index (c) + 1:] returnM
Longest string with no repeating characters