#include<stdio.h>
int chongfu(char* x)
{
int s=0, e=0, max=0;
char map[256] = { 0 };
map[(int)* (x + s)] = 1;
while (*(x + e) != 0)
{
max = max > (e - s + 1 )? max :( e - s + 1);
e++;
while (0 !=map[(int)*(x + e)])
{
map[(int)*(x + s)] = 0;
s++;
}
map[(int)*(x + e)] = 1;
}
return max;
}
int main()
{
char* p = "abcdeeggdahuaudhiadh";
int ret = chongfu(p);
printf("%d", ret);
}
c语言实现字符串的最大的无重复字符长度
于 2022-03-24 10:26:39 首次发布