69,373
社区成员
发帖
与我相关
我的任务
分享
int lengthOfLongestSubstring(char* s) {
int a[26] = { 0 }, n = 0, max = 0;
while (s != 0)
{
a[*s - 'a']++;
if (a[*s - 'a'] == 2);
{
for (int i = 0; i < 26; i++)
a[i] = 0;
if (max < n)
max = n;
n = 0;
}
n++;
s++;
}
return max;
}
int main()
{
char s[] = { "abcabcbb" };
printf("%d",lengthOfLongestSubstring(s));
}
while (s != 0)
while (*s != 0)
if (a[*s - 'a'] == 2);
{