Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length
of 1.
思路:
用两个指针i和j遍历整个字符串。i不断向前移动,同时记录碰到的字符。如果这个字符在i和j之间已经遇到过,则将j移动到i,j之间的这个字符的下一个位置。移动i,j的同时更新字符串的长度。
......
阅读全文