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. ACM/ICPC2014鞍山现场赛E hdu5074Hatsune Miku

    题目链接:pid=5074">http://acm.hdu.edu.cn/showproblem.php?pid=5074 题意: 给定一个m*m的矩阵mp.然后给定一个长度为n的序列 ...

  2. C# in Depth阅读笔记2:C#2特性

    1.方法组转换 c#2支持一个从方法组到兼容委托类型的隐式转换,即如: button.click+=new eventhandler(logevent)可以写成 button.click+=logev ...

  3. javaScript 工作必知(十) call apply bind

    call  每个func 都会继承call apply等方法. function print(mesage) { console.log(mesage); return mesage; } print ...

  4. HBASE学习笔记--概述

    定义: HBase是一个分布式的.面向列的开源数据库,HBase是Google Bigtable的开源实现,它利用Hadoop HDFS作为其文件存储系统,利用Hadoop MapReduce来处理H ...

  5. datagrid指定行合并导出

    导出代码: public void GridViewToExcel(GridView ctrl, string FileType, string FileName) { HttpContext.Cur ...

  6. How to select a CRAN mirror in R & use repos parameter(2)

    首次添加功能包需要设定CRAN镜像库: 方法是依据提示:--- Please select a CRAN mirror for use in this session ---,在弹出的窗口中选择CRA ...

  7. 剑指offier第4题

    /* 问题1:替换字符串,是在原来的字符串上做替换,还是新开辟一个字符串做替换! 问题2:在当前字符串替换,怎么替换才更有效率(不考虑java里现有的replace方法). 从前往后替换,后面的字符要 ...

  8. CCF计算机认证——字符串匹配问题(运行都正确,为什么提交后只给50分?)

    我的程序: #include<iostream> #include<cctype> #include<string> #include<vector> ...

  9. jquery鼠标滑过展示图片时显示详情

    jquery: <script src="js/jquery.js" type="text/javascript"></script> ...

  10. Flink资料(3)-- Flink一般架构和处理模型

    Flink一般架构和处理模型 本文翻译自General Architecture and Process Model ----------------------------------------- ...