leetcode 3. Longest Substring Without Repeating Characters
来源:互联网 发布:知乎 盛世美颜 编辑:程序博客网 时间:2024/05/16 05:21
Given a string, find the length of the longest substring without repeating characters.
Examples:
Given "abcabcbb"
, the answer is "abc"
, which the length is 3.
Given "bbbbb"
, the answer is "b"
, with the length of 1.
Given "pwwkew"
, the answer is "wke"
, with the length of 3. Note that the answer must be a substring, "pwke"
is a subsequence and not a substring.
给定一个字符串,求出最长的没有重复字符的子串的长度
public class A3LongestSubstring {public int lengthOfLongestSubstring(String s) {if(s.length() == 0 || s == null) {return 0;}int[] length = new int[s.length()];length[0] = 1;for(int i = 1,j; i < s.length(); i++) {for(j = i - 1; j != -1 && s.charAt(i) != s.charAt(j); j--) {}if(j < 0) {length[i] = i + 1;} else {length[i] = i - j;}if(length[i] > length[i - 1] + 1) {length[i] = length[i - 1] + 1;}}Arrays.sort(length); return length[s.length() - 1]; }}
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] 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
- (Leetcode)3. Longest Substring Without Repeating Characters
- leetcode 3. Longest Substring Without Repeating Characters
- LeetCode-3. Longest Substring Without Repeating Characters
- 双联通
- java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 在指定的 DSN 中,驱动程 序和应用程序之间的体系结构不匹配
- Android edittext默认不获取焦点
- ConcurrencyHashMap的线程安全示例
- 传日期执行脚本
- leetcode 3. Longest Substring Without Repeating Characters
- HttpClient更新下载apk
- 350. Intersection of Two Arrays II【E】
- Hibernate命名查询、本地SQL、自定义SQL、存储过程
- 软件密码学基础和配置tomcat的https连接器
- node http模块学习笔记
- Android textview设置字体
- 在cocos2dx 3.x 中实现带颜色滤镜的Sprite
- Android水波纹扩散效果