leetcode Longest Substring Without Repeating Characters
来源:互联网 发布:minitab软件免费下载 编辑:程序博客网 时间:2024/06/05 05:33
问题描述:
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) { int n, maxVal; n = s.length(); maxVal = n == 0 ? 0 : 1; for (int i = 1; i < n; i++) { int cur = 1; for (int j = i - 1; j >= 0 && s[j] != s[i]; cur++, j--); if (cur > maxVal) { maxVal = cur; } } return maxVal; }};
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
- 浅析为什么char类型的范围是 —128~+127
- 随笔
- 抓包分析工具
- OJ刷题之《计算题》
- 关于信号量
- leetcode Longest Substring Without Repeating Characters
- LEETCODE: Remove Duplicates from Sorted List II
- MyEclipse10 不停的 Validating...
- linux ubuntu 下 crystalanalysis 的安装步骤
- 判断100到200间的素数的算法+优化~
- linux ubuntu 下 phonopy 的安装步骤
- [UVA12230] Crossing Rivers && 数学期望
- 文本数据交换格式:JSON
- 南京哥帝KTV、塞尚风情 都是骗子 他们二楼是个专门骗人的地方