代码实现:
解法一:暴力法
int lengthOfLongestSubstring(char *s) { int hash[256] = {0}; int num = 0; for (int i = 0; i < strlen(s); i++) { int count = 0; for (int j = i; j < strlen(s); j++) { if (hash[s[j]] == 0) { hash[s[j]]++; count++; num = num > count ? num : count; } else { memset(hash, 0, sizeof(hash)); break; } } } return num; }