首页 > 代码库 > Longest Substring Without Repeating Characters

Longest Substring Without Repeating Characters

int longestSubString(char* arr, int len){    if (arr == NULL || len <= 0)        return 0;    int i = 0, j = 0;    int maxLen = 0;    bool exist[256] = { false };    while (j < len)    {        if (exist[s[j]])        {            maxLen = max(maxLen, j-i);            while (s[i] != s[j])            {                exist[s[i]] = false;                i++;            }            i++;            j++;        }        else        {            exist[s[j]] = true;            j++;        }    }    maxLen = max(maxLen, len-i);    return maxLen;}

 

Longest Substring Without Repeating Characters