leetcode-Longest Substring Without Repeating Characters
来源:互联网 发布:深圳市软件产业基地5栋 编辑:程序博客网 时间:2024/06/08 19:41
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.
思路:
1,用一个hash记录字符出现过的位置
2,从头开始遍历字符串,记录无重复子串的长度,如果扫描到重复字符,则从重复字符处的下一个开始扫描。
如:str[]="abcabcbb"
a,str[0]==str[3] 最长子串长度3,从str[1]开始继续扫描
b,str[1]==str[4]最长子串长度3,从str[2]继续扫描
c,str[2]==str[5]最长子串长度3,从str[3]继续扫描
d,str[4]==str[6]最长子串长度3,从str[5]继续扫描
e,str[6]==str[7]最长子串长度3,扫描结束
0 0
- LeetCode: Longest Substring Without Repeating Characters
- LeetCode Longest Substring Without Repeating Characters
- LeetCode: Longest Substring Without Repeating Characters
- [Leetcode] Longest Substring Without Repeating Characters
- leetcode 23: Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- LeetCode 3 - Longest Substring Without Repeating Characters
- [LeetCode]Longest Substring Without Repeating Characters
- leetcode Longest Substring Without Repeating Characters
- 【leetcode】 Longest Substring Without Repeating Characters
- LeetCode-Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- [leetcode] Longest Substring Without Repeating Characters
- LeetCode - Longest Substring Without Repeating Characters
- LeetCode 3: Longest Substring Without Repeating Characters
- leetcode-3:Longest Substring Without Repeating Characters
- leetcode之Longest Substring Without Repeating Characters
- EDMA3的传输配置步骤,翻译自sprugx8b 5.7Setting Up a Transfer
- 使用tintColor改变图片的颜色
- ibatis源码分析
- typedef巧用和注意事项
- 常用软件自动化测试工具介绍
- leetcode-Longest Substring Without Repeating Characters
- java中子类继承父类时是否继承构造函数呢?
- Ubuntu 下disk清理保护
- find 命令
- Unity3d发送邮件
- cocos2dx mac环境搭建
- 黑马程序员_面向对象_静态&单例
- TransactionTemplate源码分析
- MFC编程时的一些小知识(三)