Leetcode:Longest Substring Without Repeating Characters
来源:互联网 发布:嘀哩嘀哩软件下载 编辑:程序博客网 时间:2024/06/04 19:58
这题目比较简单,遍历整个s,比较是否重复即可。
class Solution(object): def lengthOfLongestSubstring(self, s): sub,t = set(),[] i,n,longest,L = 0,len(s),0,0 offset = 0 while i<n: ch = s[i] if ch not in sub: sub.add(ch) t.append(ch) i,L=i+1,L+1 if L-offset>longest:longest = L-offset else: x,offset = t[offset],offset+1 sub.remove(x) return longest
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
- Android 6.0 PowerManagerService状态分析
- unity dll实现热更新
- 1007. Maximum Subsequence Sum (25)
- C++ 数据结构-------栈实现
- gvim中复制到系统剪贴板
- Leetcode:Longest Substring Without Repeating Characters
- Java-最近面试笔试总结
- mysql修改字段类型
- Android 使用友盟等分享出现乱码的解决方案
- 微软2016校招笔试题
- BZOJ 1597 [Usaco2008 Mar]土地购买
- Leetcode005--字符串中最大的回文子串
- 只要两行代码,就能判断一个App是否在前台运行
- 【Phalcon实现高性能接口开发】使用Phalcon高性能PHP框架搭建API MVC架构之实现查询版本的接口