【leetcode】第3题:求最长不重复(字符不重复)的子串的长度

#include
#include
int lengthOfLongestSubString(char *s){
	int len = 0;
	char *addressTable[128] ={NULL};
	char *p =s,*temp;
	while(*p){
		temp = addressTable[*p];
		addressTable[*p] = p;
		if(temp>=s){
			len = p-s>len?p-s:len;
			s = temp+1;
		}
		p++;
	}
	len = p-s>len?p-s:len;
	return len;
}

void main(){
	char *str = "abcdaccc";
	printf("%d",lengthOfLongestSubString(str));
}

你可能感兴趣的:(LeetCode)