Longest Substring Without Repeating Characters
来源:互联网 发布:微信淘宝优惠群真实吗 编辑:程序博客网 时间:2024/04/29 22:00
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. For "bbbbb" the longest substring is "b", with the length of 1.
#include<map>class Solution {public: int lengthOfLongestSubstring(string s) { int max=0; map<char,int> last; int start=0; for(int i=0;i<s.size();i++) { if(last.find(s[i])!=last.end()&&last[s[i]]>=start){ max=(i-start)>max?(i-start):max; start=last[s[i]]+1; } last[s[i]]=i; } return (s.size()-start)>max?(s.size()-start):max; }};
0 0
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- Longest Substring Without Repeating Characters
- 【百度之星2014~复赛)解题报告】The Query on the Tree
- OCP 1Z0 051 175
- RT5350原厂SDK及AP移植步骤详解
- DedeCMS站内新闻出错\include\taglib\mynews.lib.php on line 16
- 易语言 取自定义数据类型的大小
- Longest Substring Without Repeating Characters
- git 入门教程
- 序列化的作用
- 似一种无悔的修行,
- Python/Twisted 异步编程教程
- 2014java基础笔记
- git windows下搭建全过程
- javaIO流,字符流详解
- hdoj 1306 String Matching