[LeetCode Solution]3.Longest Substring Without Repeating Characters
来源:互联网 发布:windows域搭建 编辑:程序博客网 时间:2024/06/02 07:27
问题描述如题。
假设所有字符均属于ASCII字码表
int lengthOfLongestSubstring(char* s) { int maxLen = 0; int nStart = 0; //滑动窗口的其实位置 int nEnd = 0; //滑动窗口的结束位置 char index[256] = {0}; //用于标记字符是否已经存在于子字符串中 while(s[nEnd] != 0) { if(index[s[nEnd]] == 0) { index[s[nEnd++]] = 1;//标记,并将尾巴像右移动 int nLen = nEnd - nStart; maxLen = maxLen > nLen ? maxLen : nLen; } else { index[s[nStart++]] = 0;//取消标记,并将起始位置向右移动 } } return maxLen;}
阅读全文
0 0
- solution of LeetCode 3. Longest Substring Without Repeating Characters
- [LeetCode Solution]3.Longest Substring Without Repeating Characters
- LeetCode #3 Longest Substring Without Repeating Characters C# Solution
- [LeetCode]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
- [leetcode] 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
- 【Leetcode】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
- LeetCode - 3.Longest Substring Without Repeating Characters
- Leetcode 3. Longest Substring Without Repeating Characters
- 3. Longest Substring Without Repeating Characters LeetCode
- spring的IOC
- Mac Centos7-Zookeeper 第一天
- pat 乙级 1041. 考试座位号(15)
- Android学习之自定义ViewGroup
- meta部分参数
- [LeetCode Solution]3.Longest Substring Without Repeating Characters
- codeforces 850c sg函数
- Java使用Protocol Buffers入门四步骤
- 数据结构(C语言)线性表 -单链表
- 设计模式
- 【转载】常用分词方法总结分析
- css/html笔试题1
- Java常见面试(8)
- 分类与回归