Leetcode 3. Longest Substring Without Repeating Characters(python)
2016-03-27 20:40
513 查看
要判断最后一个不重复的子串是不是最长
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ if len(s)<=1: return len(s) point=0 maxl=0 for index in range(1,len(s)): if s[index] in s[point:index]: l=index-point if l>=maxl: maxl=l point+=s[point:index].index(s[index])+1 if index-point+1>maxl: maxl=index-point+1 return maxl
相关文章推荐
- Python 生成器 匿名生成器
- Leetcode 2. Add Two Numbers(python)
- Python3.x学习笔记(一)
- Leetcode 1. Two Sum(python)
- 我的Python学习之路之基本语法-函数
- 树莓派瞎玩~5~控制GPIO之Python
- 简单的抓取淘宝关键字信息、图片的Python爬虫|Python3中级玩家:淘宝天猫商品搜索爬虫自动化工具(第二篇)
- python filter, map, reduce, lamda
- 解决im.show()不能显示图片问题
- Python3基本数据类型
- Numpy 初试
- Python回顾与整理7:文件和输入输出
- Python回顾与整理7:文件和输入输出
- 【爬虫】python requests模拟登录知乎
- python轻量级爬虫的编写
- Python图像处理之伪彩色增强
- Python图像处理之边缘检测
- python绘图示例
- vim安装YouCompleteMe插件,与python补全插件jedi-vim
- python查看类的定义