Given a string, find the length of the longest substring without repeating characters.
Examples:
Given “abcabcbb”, the answer is “abc”, which the length is 3.
Given “bbbbb”, the answer is “b”, with the length of 1.
Given “pwwkew”, the answer is “wke”, with the length of 3. Note that the answer must be a substring, “pwke” is a subsequence and not a substring.
Subscribe to see which companies asked this question.
记录开始字符的位置,循环字符串s的每一个字符,判断当前字符是不是与位置在start与当前字符之间是否一致。如果一致则调整start位置为前一个字符的位置+1。
新闻热点
疑难解答