Leedcode题解
来源:互联网 发布:网络杀毒软件有哪些 编辑:程序博客网 时间:2024/06/10 10:57
3. Longest Substring Without Repeating Characters
class Solution {
public:
int i;
int lengthOfLongestSubstring(string s) {
int j;
int c;
int count=1;
if(s=="")return 0;
bool dj=true;//"abca"
for(i=0;i<s.length();i++){//string起点遍历
dj=true;
for(j=i+1;j<s.length();j++)//末点遍历
{
for(c=i;c<j;c++)
{if(s[c]==s[j]){
dj=false;
break;}
}
if(!dj)
break;
count=(count<(j-i+1)?(j-i+1):count);
}
}
return count;
}
};
注意:第一先写思维的流程图;第二注意用例测试的特殊性,“”,“bbbbb”,
0 0
- Leedcode题解
- LEEDCODE 12 Integer to Roman (JAVA题解)
- LEEDCODE 13 Roman to Integer (JAVA题解)
- LEEDCODE 14 Longest Common Prefix (JAVA题解)
- Leedcode
- leedcode
- LEEDCODE 234
- LeedCode:Sort List
- Word Break (leedcode)
- LeedCode—MinStack
- LEEDCODE: Clone Graph
- leedcode 3Sum
- LeedCode:Rotate List
- [LeedCode OJ]#120 Triangle
- [LeedCode OJ]#46 Permutations
- leedcode: Course Schedule
- 19.1 leedcode 代码位置
- LeedCode 87. Scramble String
- 教程1-创建一个窗口
- UVa 401:Palindromes
- 写在大年初一 总结2016
- 启示录:一只小白的IT路
- react-router 学习笔记
- Leedcode题解
- 神经网络 ANN(二)
- c++自制小游戏(2nd)rand与srand
- Linux关于磁盘管理的二三事(一)
- 黑苹果(Hackintosh)驱动Intel HD 4600
- leetcode104 Maximum Depth of Binary Tree
- VTK修炼之道36:图像平滑_均值滤波器
- hiho一下 第135周 九宫 (枚举幻方)
- Recurrent Neural Network系列3--理解RNN的BPTT算法和梯度消失