FTPrep, 30 Substring with Concatenation of All Words
来源:互联网 发布:国内人脸数据库 编辑:程序博客网 时间:2024/06/14 22:17
写这到hard之前,据说要先写一个道 简单对照物 来热身,于是5mins 完成了这段断代码,是LC第3题,Longest Substring Without Repeating Characters
public class Solution { public int lengthOfLongestSubstring(String s) { int len = s.length(); if(len==0|| len==1) return len; int back=0; int maxLen=1; HashSet<Character> set= new HashSet<>(); for(int front=0; front<len; ++front){ if(!set.add(s.charAt(front))){ maxLen=Math.max(maxLen, front-back); while(s.charAt(back)!=s.charAt(front)){ set.remove(s.charAt(back)); back++; } back++; } } return maxLen=Math.max(maxLen, len-1-back+1); }}
阅读全文
0 0
- FTPrep, 30 Substring with Concatenation of All Words
- 30 Substring with Concatenation of All Words
- 30Substring with Concatenation of All Words
- 30Substring with Concatenation of All Words
- 【30】Substring with Concatenation of All Words
- LeetCode: Substring with Concatenation of All Words
- LeetCode : Substring with Concatenation of All Words
- LeetCode29: Substring with Concatenation of All Words
- [Leetcode] Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- [LeetCode]Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- LeetCode-Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- 26 - Substring with Concatenation of All Words
- LeetCode:Substring with Concatenation of All Words
- Leetcode: Substring with Concatenation of All Words
- 习题 5.5 求s=a+aa+aaa+···aa···a之值,其中a是一个数字,n表示a的位数,n由键盘输入。
- MyBatis中的statementType详解
- C++ tcp/ip网络编程中listen函数和accept函数详解和区别
- windows系统的hosts文件无法修改
- 欢迎使用CSDN-markdown编辑器
- FTPrep, 30 Substring with Concatenation of All Words
- 【POJ】2312-Battle City(优化的广度搜索BFS)
- requireJs学习心得
- 不容易系列之(3)—— LELE的RPG难题 简单递推
- 简单的窗口拖动
- ES6顶层对象的属性
- unity 计算时间的插差值
- Codeforces 592D
- 有监督学习(分类、回归)