LeetCode:Longest Substring Without Repeating Characters
来源:互联网 发布:太祖 知乎 编辑:程序博客网 时间:2024/06/05 17:55
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.
int lengthOfLongestSubstring(string s) { int hashtable[256];memset(hashtable,-1,sizeof(hashtable));int length=s.length(),cur=0,maxLength=0,curLength=0,index=0;char ch=' ';if(length==0) return 0;if(length==1) return 1;while (index<length){cur=index;while (cur<length){ch=s.at(cur);cur++;if(hashtable[ch]==-1){hashtable[ch]=0;curLength++;}else if(hashtable[ch]==0){if(maxLength<curLength){maxLength=curLength;}curLength=0;memset(hashtable,-1,sizeof(hashtable));break;}}index++;}return maxLength;
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
- UML类图几种关系的总结
- LeetCode:Merge Two Sorted Lists
- [android]Android随笔:另类用法
- json解析
- 关于GDI+产生OutOfMemory问题及GDI+用法概要
- LeetCode:Longest Substring Without Repeating Characters
- Grep学习笔记
- Mac问题笔记
- XEIM 用的 CFile 读写CString
- 书生教你cocos2d-x入门篇(三)—屏幕适配
- Servlet 3.0 新特性详解
- Ember学习(7):Bindings
- C语言控制换行输出
- 数据结构之队列的顺序存储