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。
新聞熱點
疑難解答