leetcode Longest Substring Without Repeating Characters python
class Solution(object):
def lengthOfLongestSubstring(self, s):
"""
:type s: str
:rtype: int
"""
if len(s) <= 0:
return 0
res = list()
maxLen = 0
for i in s:
if i in res:
tmpLen = len(res)
if tmpLen > maxLen:
maxLen = tmpLen
while True:
tmp = res.pop(0)
if tmp == i:
break
res.append(i)
else:
res.append(i)
cnt = len(res)
if cnt > maxLen:
maxLen = cnt
return maxLen
leetcode Longest Substring Without Repeating Characters python的更多相关文章
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串
Given a string, find the length of the longest substring without repeating characters. For example, ...
- leetcode: longest substring without repeating characters
July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...
- Leetcode3:Longest Substring Without Repeating Characters@Python
Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串
Given a string, find the length of the longest substring without repeating characters. Example 1: In ...
- C++ leetcode Longest Substring Without Repeating Characters
要开学了,不开森.键盘声音有点大,担心会吵到舍友.今年要当个可爱的技术宅呀~ 题目:Given a string, find the length of the longest substring w ...
- [LeetCode]Longest Substring Without Repeating Characters题解
Longest Substring Without Repeating Characters: Given a string, find the length of the longest subst ...
- [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串 C++实现java实现
最长无重复字符的子串 Given a string, find the length of the longest substring without repeating characters. Ex ...
- LeetCode:Longest Substring Without Repeating Characters(最长不重复子串)
题目链接 Given a string, find the length of the longest substring without repeating characters. For exam ...
- LeetCode——Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, ...
随机推荐
- The Unique MST (判断是否存在多个最小生成树)
The Unique MST Time Limit: 10 ...
- 问题解决——Group Box控件遮挡其它控件
转载请保持文章的完整性并显要地注明出处 本文链接:http://blog.csdn.net/wlsgzl/article/details/38042301 ====================== ...
- windows编程之菜单操作
分清几个概念 <1>"主菜单" 和 "顶层菜单" 是一个意思. <2>主菜单中的项目叫做 "弹出菜单" 或者 &qu ...
- C#中使用日志类,添加dll时出现错误
警告 1 未能解析引用的程序集 “log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, proces ...
- data按钮
1.加载状态 通过按钮(Button)插件,您可以添加进一些交互,比如控制按钮状态,或者为其他组件(如工具栏)创建按钮组. 如需向按钮添加加载状态,只需要简单地向 button 元素添加 data-l ...
- CRM后期修改实体,新增货币类型字段 需要注意的问题
货币类型字段新增 需要处理历史数据 否则编辑会报错 提示如果货币字段中存在值,则需要指定币种,请选择币种,然后重试 编辑时货币字段不显示¥符号.新增正常.第一次编辑提示错误保存后再编辑也正常.不是JS ...
- SQL数据库知识二(Day 25)
又到了总结知识的时候了,今天主要把SQL数据库给简单的学完了,明天开始就要开始学ADO.NET的知识了.好了,话不多说,还是看一下今天都学了哪些内容. 1 字符串类型的知识点 --类型的使用 --截 ...
- Angular基础知识
AngularJS 是一个 JavaScript 框架.它可通过 <script> 标签添加到 HTML 页面. AngularJS 通过 ng-directives 扩展了 HTML. ...
- VBA基础——循环语句
VBA基础之循环语句 Sub s1() Dim rg As Range For Each rg In Range("a1:b7,d5:e9") If rg = "&quo ...
- enum枚举类型 的用法
1.作为数组下标使用 enun box{pencil, ruler}; void main() { string s[2]; s[pencil]="pencil"; s[rule ...