3. Longest Substring Without Repeating Characters
来源:互联网 发布:itools怎么下载软件 编辑:程序博客网 时间:2024/05/16 07:42
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 subsequenceand not a substring.
class Solution {public: int lengthOfLongestSubstring(string s) { set<char> substring; int size=s.length(); int *p=new int[size]; int count=0; for(int i=0;i<size;i++) { for(int j=i;j<size;j++) { if(substring.find(s[j])!=substring.end()) { break; } else { substring.insert(s[j]); count++; } } p[i]=count; substring.clear(); count=0; } count=0; for(int i=0;i<size;i++) { if(p[i]>count) count=p[i]; } return count; }};
阅读全文
0 0
- [LeetCode]3.Longest Substring Without Repeating Characters
- LeetCode 3.Longest Substring Without Repeating Characters
- LeetCode --- 3. Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- [Leetcode] 3. Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- 3. Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- 3. Longest Substring Without Repeating Characters
- [leetcode] 3.Longest Substring Without Repeating Characters
- 3.Longest Substring Without Repeating Characters
- [leetcode] 3. Longest Substring Without Repeating Characters
- 3. Longest Substring Without Repeating Characters
- [Leetcode]3. Longest Substring Without Repeating Characters
- leetcode 3. Longest Substring Without Repeating Characters
- 【Leetcode】3. Longest Substring Without Repeating Characters
- IDA出现"sp-analysis failed"和F5(反编译)失败
- 使用VS2013调用opencv3.3.0时出现的问题及解决办法
- Android 资源网站
- jquery实现来回翻转效果
- HDU(3592)---POJ (3169) Layout 差分约束系统
- 3. Longest Substring Without Repeating Characters
- Lnmp常用小知识
- CocosCreator学习2:场景的创建和切换
- 第三章 资源管理
- C指针分享之“复杂指针”
- redis集群哨兵模式
- CocosCreator零基础制作游戏《极限跳跃》二、制作游戏开始场景
- LinkList ArrayList 深入研究对比
- opencv中人脸识别算法的基本原理(二)