最长子字符串-无重复字符
来源:互联网 发布:中文安卓编程 编辑:程序博客网 时间:2024/05/21 06:37
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb"
, the answer is "abc"
, which the length is 3.
Given "bbbbb"
, the answer is "b"
, with the length of 1.
Given "pwwkew"
, the answer is "wke"
, with the length of 3. Note that the answer must be a substring, "pwke"
is a subsequence and not a substring.
class Solution(object): def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ ilen = 0 iStart = iEnd = 0 for a in s: pos = s[iStart:iEnd].find(a) if pos >= 0: if ilen < iEnd - iStart: ilen = iEnd - iStart iStart += pos + 1 iEnd += 1 if ilen < iEnd - iStart: ilen = iEnd - iStart return ilen
空字符串开始,遇到重复调整字符串
阅读全文
0 0
- 最长子字符串-无重复字符
- 求字符串中最长无重复字符的子串
- 求字符串中最长无重复字符的子串
- 查找字符串中最长无重复字符的子串
- 求字符串中最长无重复字符的子串
- 求字符串中最长无重复字符的子串
- 求字符串的最长无重复字符子串(C++)
- 求字符串中最长无重复字符的子串
- 字符串中最长无重复字符的子串
- 求字符串中最长无重复字符的子串
- 求字符串中最长无重复字符的子串
- 找到字符串的最长无重复字符子串
- 字符串12:最长无重复字符子串练习题
- leetcode 3-最长无重复字符的子字符串
- 找到字符串中无重复最长的字符子串
- 找到字符串的最长无重复字符子串
- 最长无重复子字符串
- 最长无重复字符的子串
- android 4.0以上横竖屏切换不销毁activity,不重新走生命周期,只调用onConfigurationChanged
- 第 4 章 模型
- 算法——最短路径——Dijkstra算法
- javax.ws.rs.BadRequestException: HTTP 400 Bad Request错误处理
- HDOJ1242 基础宽搜题
- 最长子字符串-无重复字符
- js事件
- 快速排序和归并排序的实现
- 工具解析|杀毒引擎惨遭打脸,黑帽大会爆惊天免杀工具
- 事件
- [Python]重载运算符
- 文件系统编程的应用
- murmur2
- 从xml文件中获取相关数据,解决xml中部分数据没有结束的问题