#include<iostream>
using namespace std;
class Solution {
public:
int Length(string s)
{
int strat = 0, end = 0, length = 0, result = 0;
char tmpchar;
int siz = int(s.size());
while (end < siz)
{
tmpchar = s[end];
for (int index = strat; index < end; index++)
{
if (tmpchar == s[index]) {
strat = index + 1;
length = end - strat;
break;
}
}
end++;
length++;
result = max(result, length);
}
return result;
}
};
int main() {
string s = "bbbbb";
Solution solution;
cout << solution.Length(s) << endl;
return 0;
}
给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。
最新推荐文章于 2023-11-29 18:45:50 发布