leetcode-Longest Substring Without Repeating Characters
来源:互联网 发布:优惠券系统源码 编辑:程序博客网 时间:2024/05/05 01:00
Difficulty:Medium
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.
class Solution {public: int lengthOfLongestSubstring(string s) { if(s.empty()) return 0; map<char,int> check; int pre=0; int length=s.length(); int maxLen=INT_MIN; for(int i=0;i<length;++i){ if(check.find(s[i])!=check.end()&&pre<=check[s[i]]) pre=check[s[i]]+1; maxLen=max(maxLen,i-pre+1); check[s[i]]=i; } return maxLen; }};
0 0
- LeetCode: Longest Substring Without Repeating Characters
- LeetCode Longest Substring Without Repeating Characters
- LeetCode: Longest Substring Without Repeating Characters
- [Leetcode] Longest Substring Without Repeating Characters
- leetcode 23: Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- LeetCode 3 - Longest Substring Without Repeating Characters
- [LeetCode]Longest Substring Without Repeating Characters
- leetcode Longest Substring Without Repeating Characters
- 【leetcode】 Longest Substring Without Repeating Characters
- LeetCode-Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- [LeetCode] Longest Substring Without Repeating Characters
- [leetcode] Longest Substring Without Repeating Characters
- LeetCode - Longest Substring Without Repeating Characters
- LeetCode 3: Longest Substring Without Repeating Characters
- leetcode-3:Longest Substring Without Repeating Characters
- leetcode之Longest Substring Without Repeating Characters
- Hadoop---安装Fuse-DFS(难)
- OPENGL的位图和图象
- Android应用性能剖析全攻略
- comparator接口与Comparable接口的区别
- Mysql调优
- leetcode-Longest Substring Without Repeating Characters
- Ubuntu 14.04登录输入用户名密码之后重新跳回登录界面
- LightOJ - 1184 Marriage Media(二分图匹配)
- poj3009urling 2.0(AC2)
- git_community_book_notes:Introduction
- 在Canvas上显示动画
- ReentrantLock与Condition
- git_community_book:ch2_basic_usage
- Android 打开闪光灯关键代码-转载