题目描述
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.
问题分析
这个题寻找最长的不重复字串,即在一个字符串里面,所有的字符都没有出现,可以定义个表,用来记录每一个字符第一次出现的位置,当发现有位置已经有字符了,将下表移动到index+1的位置,同时不断记录最长字串长度。
代码
public class Solution {