Leetcode: Longest Substring Without Repeating Characters
来源:互联网 发布:java电信资费系统 编辑:程序博客网 时间:2024/06/07 07:22
Question
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.
Hide Tags Hash Table Two Pointers String
Hide Similar Problems (H) Longest Substring with At Most Two Distinct Characters
My Solution
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if s=='': return 0 res, start = 0, 0 dictn = {} for ind in range(len(s)): if s[ind] not in dictn: dictn[s[ind]] = 1 res = max(res, len(dictn)) else: while s[start]!=s[ind]: del dictn[s[start]] start += 1 start += 1 return res
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
- 关于牛气轰轰的闭包
- java虚拟机回收机制原理
- 回调函数和钩子函数
- 蓝懿教育记录
- LeetCode Minimum Path Sum
- Leetcode: Longest Substring Without Repeating Characters
- Add Digits
- #读书笔记#《The Art of Software Testing》——第六章
- kernel-firmware
- bzoj-1128 Lam
- Bash shell中的位置参数$#,$*,$@,$0,$1,$2...及特殊参数$?,$-等的含义
- 使用CentOS DVD1 和DVD2做本地yum源
- HashMap
- 成为Java GC专家(4)—Apache的MaxClients参数详解及其在Tomcat执行FullGC时的影响