Leetcode#3 Longest Substring Without Repeating Characters
来源:互联网 发布:c socket传输json 编辑:程序博客网 时间:2024/04/30 18:07
Difficulty:Medium
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 a[256]; memset(a, -1, sizeof(a)); int ans=0, start=0, end1=0; for(int i =0; i<s.length();i++){ if(a[s[i]]==-1){ end1++; ans = ans>(end1-start)?ans : (end1-start); a[s[i]]=i; } else{ if(a[s[i]]>=start) start=a[s[i]]+1; end1++; ans = ans>(end1-start)?ans : (end1-start); a[s[i]]=i; } } return ans; }
0 0
- 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 3LONGEST 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]3Longest 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
- linux下的系统调用函数到内核函数的追踪
- 在结构体最后定义一个长度为0的字符数组(技巧)
- 向Linux内核添加系统调用函数
- 生活的美好
- 欢迎使用CSDN-markdown编辑器
- Leetcode#3 Longest Substring Without Repeating Characters
- TrustZone的一些理解
- mybatis分享
- Swing下拉复选框菜单
- mex 传递参数格式问题
- Xcode7 使用NSURLSession发送HTTP请求报错
- Nagios客户端安装
- #leetcode#Kth Smallest Element in a BST
- 驽哗咎猁土钙骛禄刂夼放骚妨空克玖馀么欺产愦止塌菪蚤萍