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的更多相关文章

  1. [LeetCode] Longest Substring Without Repeating Characters 最长无重复子串

    Given a string, find the length of the longest substring without repeating characters. For example, ...

  2. leetcode: longest substring without repeating characters

    July 16, 2015 Problem statement: Longest Substring Without Repeating Characters Read the blog: http: ...

  3. Leetcode3:Longest Substring Without Repeating Characters@Python

    Given a string, find the length of the longest substring without repeating characters. Examples: Giv ...

  4. [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串

    Given a string, find the length of the longest substring without repeating characters. Example 1: In ...

  5. C++ leetcode Longest Substring Without Repeating Characters

    要开学了,不开森.键盘声音有点大,担心会吵到舍友.今年要当个可爱的技术宅呀~ 题目:Given a string, find the length of the longest substring w ...

  6. [LeetCode]Longest Substring Without Repeating Characters题解

    Longest Substring Without Repeating Characters: Given a string, find the length of the longest subst ...

  7. [LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串 C++实现java实现

    最长无重复字符的子串 Given a string, find the length of the longest substring without repeating characters. Ex ...

  8. LeetCode:Longest Substring Without Repeating Characters(最长不重复子串)

    题目链接 Given a string, find the length of the longest substring without repeating characters. For exam ...

  9. LeetCode——Longest Substring Without Repeating Characters

    Given a string, find the length of the longest substring without repeating characters. For example, ...

随机推荐

  1. vpn pptp配置

    安装 yum install pptpd 配置pptpd 改动/etc/pptpd.conf设置 localip 192.168.20.1 remoteip 192.168.20.234-238,19 ...

  2. linux内核源码阅读之facebook硬盘加速flashcache之六

    其实到目前为止,如果对读流程已经能轻松地看懂了,那么写流程不需要太多脑细胞.我觉得再写下去没有太大的必要了,后面想想为了保持flashcache完整性,还是写出来吧.接着到写流程: 1530stati ...

  3. uva 103 Stacking Boxes(DAG)

    题目连接:103 - Stacking Boxes 题目大意:有n个w维立体, 输出立体互相嵌套的层数的最大值, 并输出嵌套方式, 可嵌套的要求是外层立体的w条边可以分别对应大于内层立体. 解题思路: ...

  4. C++关注备注部分知识点

    //关注备注部分知识点. #include <iostream> #include <string><span style="white-space:pre&q ...

  5. MSSQL查询连接数

    SELECT * FROM [Master].[dbo].[SYSPROCESSES] WHERE [DBID] IN ( SELECT [DBID] FROM [Master].[dbo].[SYS ...

  6. [转]Visual Studio 2008中如何比较二个数据库的架构【Schema】和数据【Data】并同步

    使用场景: 在团队开发中,每一个人都有可能随时更新数据库,这时候数据库中数据和架构等信息都会发生变化.如果更新不及时,就会发生数据错误或数据丢失的风险,影响团队的开发效率和 项目进度,这时候我们该怎么 ...

  7. PHP程序输出日历

    以下代码只是简单实现日历的效果和逻辑思路,没有使用类封装,权当抛砖引玉,有兴趣的朋友可以封装起来,方便调用. <?php /** * PHP利用时间函数输出日历 * Rain.zen $ int ...

  8. 记一次SQL联合查询注入工具的编写

    这是一个ASP网站的简单SQL注入检测和利用的工具,主要的功能是简单的检测出SQL注入漏洞,可以使用该id存在的SQL注入来获取数据库中的网站管理员的表名和字段名,猜解数据库中该表的字段数,最后通过联 ...

  9. C/C++招聘的一些感受和经验【转】

    找工作本人认为最重要的就是前期准备了.     首先.简历一定要写的切合主题.招聘单位要的是你的技能,这个只要大概能符合就可以,关键他们需要的是你的开发经验,一定要在简历中完美的体现出你之前所参与的项 ...

  10. Distributed Machine Learning Toolkit

    http://www.dmtk.io http://www.dmtk.io/download.html