LeetCode Longest Substring Without Repeating Characters
来源:互联网 发布:ubuntu 输入法只有五笔 编辑:程序博客网 时间:2024/05/18 03:36
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 = s.length();int lengest = 0, count = 0, start = 0;if (n == 0)return count;for (int i = 0; i < n; i++) {int j = start;while (j < i) {if (s[j] == s[i])break;elsej++;}if (j < i) {if (count > lengest)lengest = count;count -= j - start;start = j + 1;continue;}else {count++;if (i == n - 1 && count > lengest)lengest = count;}}return lengest;}};
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
- ios 定位崩溃函数方法
- 几种常见排序算法
- 树中两个结点的最低公共祖先
- STL中transform ,erase,sort,unique的使用
- 为何Java中子类重写方法的访问权限不能低于父类中权限
- LeetCode Longest Substring Without Repeating Characters
- 天祥食品:月饼产业不景气,调整结构促发展
- *android判断手机号的运营商
- ERROR 1050 (42S01): Table 'crmdb/#sql-ib269' already exists
- 项目开发遇到的问题以及解决方法
- mybaitis模糊查询like格式问题解决方法
- 输入一个整形数组,数组中有正数也有负数,求该数组中所以子数组和的最大值
- Unique Paths 动态规划(重重)
- ORACLE管理常用命令大全