码迷,mamicode.com
首页 > 其他好文 > 详细

Longest Substring Without Repeating Characters

时间:2014-12-17 22:34:06      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   color   sp   on   div   log   bs   

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

标签:style   blog   ar   color   sp   on   div   log   bs   

原文地址:http://www.cnblogs.com/litao-tech/p/4170507.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!