[leetcode] Longest Substring Without Repeating Characters
来源:互联网 发布:淘宝贝幼儿园怎么样 编辑:程序博客网 时间:2024/06/10 08:36
Q: 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.
解题思路:动态规划
class Solution: # @param {string} s # @return {integer} def lengthOfLongestSubstring(self, s): if s is None or len(s)==0: return 0 if len(s)==1: return 1 dic = {} maxcount,startindex = 0,-1 for index,i in enumerate(s): if i in dic and startindex<dic[i]: startindex = dic[i] if index-startindex>maxcount: maxcount = index-startindex dic[i]=index return maxcount
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
- 图的深度优先搜索
- C++ 11 右值引用以及std::move
- 黑马程序员----超实用的多线程
- Spring揭秘:第七章-第十二章Spring AOP框架
- poj-3463 Sightseeing
- [leetcode] Longest Substring Without Repeating Characters
- ZeroMQ_官方文档C#示例
- Android-AppWidget
- V$LOCK视图的介绍和使用
- 从GDI到Direct2D:贴图
- Android屏幕图标尺寸规范
- hdu 3886 - Final Kichiku “Lanlanshu”(数位dp)多校联合
- Python - sqlalchemy Orm
- CSS规范 - 典型错误