题目:给定一个字符串,找出不含有重复字符的最长子串的长度。
题解(1):写一个判断字符串是否有相同字符的函数,再写一个函数能够将字符串拆分成所有可能的子字符串并进行相同字符存在性判断,比较所有无相同字符串的字符串长度,返回最大字符串长度。
#include "iostream"
using namespace std;
#include"unordered_map"
class solution
{
public: string str;
solution(string strs)
{
str = strs;
}
int res = 0;
int j=0;
bool judge(string str) //用于判断该字符串是否含有相同字符
{
for (int i = 0;i < str.length();i++)
{
for (int j = 0;j < i;j++