题目
Given a string, find the length of the longest substring without repeating characters.
解题思路
- 建立HashSet,定义两个变量记录作为扫描记录。
- 头变量每次扫描一个字符
- 字符不存在于HashSet中,将字符加入HashSet,记录HashSet的最大长度
- 字符存在于HashSet中,尾变量前移,直到无重复字符
代码
1 |
public int (String s) { |
Given a string, find the length of the longest substring without repeating characters.
1 |
public int (String s) { |
近期评论