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. 关于优化性能<主要是速度方面>的个人心得 【转】

    一个web项目后期的维护主要在于性能方面.数据吞吐量一旦增大各种bug都出来了.那些通过硬件<数据库分表,数据库主从分离,读写分离>等的一些手段此处就不多说了.本文主要在编码方面做一个性能 ...

  2. SDUT OJ 2783 小P寻宝记

    #include<iostream> #include<memory.h> #define N 10020 using namespace std; int dp[N],pi[ ...

  3. OAuthBase.cs

    using System; using System.Security.Cryptography; using System.Collections.Generic; using System.Tex ...

  4. servlet上传文件报错(一)

    1.详细报错例如以下: org.apache.commons.fileupload.FileUploadBase$IOFileUploadException: Processing of multip ...

  5. VS中,无法嵌入互操作类型“……”,请改用适用的接口的解决方法

    最近使用VS,在引用COM组件的时候,出现了无法嵌入互操作类型“……”,请改用适用的接口的错误提示.查阅资料,找到解决方案,记录如下: 选中项目中引入的dll,鼠标右键,选择属性,把“嵌入互操作类型” ...

  6. input模糊搜索功能

    <!doctype html> <meta charset="utf-8"> <style type="text/css"> ...

  7. C++中联合体(union)的使用

    typedef union para { ]; struct { double a; double b; double c; double d; }NP; }NPara; //或者如下所示 union ...

  8. C++ Builder平台使用Indy9开发自动FTP程序01

    Indy9与CB自带的Indy8不同处还是挺多的.首先就是图标变漂亮了,其次很多Method都重写了.它主要是依据Delph里的函数,力求与之相通.不同点在本系列的后续章节中会一一介绍. 在写ftp代 ...

  9. 调整 CComboBox 控件的下拉列表的高度

    CComboBox 控件的下拉列表的高度默认很小,很难看.网上查来查去终于发现如何设置. 很巧妙,要在设计视图上单击下拉列表的小箭头.这时会发现出来的边框和点其它的位置是不同的. 这个高度就是下拉列表 ...

  10. Zend Studio 12 大集合

    前言 本文记录了我个人使用Zend Studio 12的点点滴滴,不定时更新. 内容来源于网络,如有侵权,告知后可删除. 下载 官方链接点击链接,填入相关信息即可下载. 破解 声明:请购买正版,非万不 ...