#include <string.h>
int lengthOfLongestSubstring(char *s)
{
char bin[128] = {0};
unsigned short length = strlen(s);
unsigned short ret = 0, this_ret = 0;
for (int i = 0; i < length; i++)
{
if (bin[s[i]] != 0)
{
if (s[i - this_ret] == s[i])
continue;
if (ret < this_ret)
ret = this_ret;
while (s[i - this_ret] != s[i]){
bin[s[i-this_ret]] = 0;
this_ret --;
}
}else{
bin[s[i]] = 1;
this_ret++;
}
}
return ret<this_ret?this_ret:ret;
}