请各位看看,就是在测试用例是:""的时候不对,判断不了,怎么改能满足题意
#include <string.h>
int lengthOfLongestSubstring(char* s) {
int i,j;
int n=strlen(s);
for (i=0;i<n-1;i++)
{
for (j=i+1;j<n;j++)
{
if (s[j-1]>s[j])
{
char temp=s[j-1];
s[j-1]=s[j];
s[j]=temp;
}
}
}
int count=1;
for (i=1;i<n;i++)
{
int every=1;
for (j=i+1;j<n;j++)
{
if (s[j]!=s[j-1])
{
every++;
}
}
if (every>count)
count=every;
}
return count;
}