输入: "abcabcbb"
输出: 3
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。
https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/
#include<stdio.h>
#include<stdlib.h>
int find(char *str)
{
char *last = &str[0];
char *next = NULL;
char *tmp = NULL;
for (next = &str[1]; (*next) != '\0'; next++)
{
int a = *(next);
for (tmp = --next, ++next; tmp >= last; tmp--)
{
if (*tmp == a)
{
printf("%c\n", *tmp);
return next-last;
}
}
}
return 0;
}
int main()
{
char str[] = "abccbb";
int a=find(str);
printf("%d\n", a);
for (int i = 0; i < a; i++)
{
printf("%c", str[i]);
}
system("pause");
return 0;
}