Why is this time limit exceed??


  • 0
        if(s.length()==0)
            return 0;
        int length = s.length();
        int l[length] = {0};
        int g[length] = {0};
        l[0] = 1;
        g[0] = 1;
        for(int i=1;i<length;i++)
        {
            l[i]=0;
            for(int j = i;j>=0;j--)
            {
                vector<int> arr(256,0);
                if(arr[s[j]]==0)
                {
                    arr[s[j]]++;
                    l[i]++;
                }
                else
                {
                    break;
                }
            }
            g[i] = max(g[i-1],l[i]);
        }
        return g[length-1];

  • 0

    I have solve this problem,but the time is very large.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.