JS solution got error when the testcase is super long


  • 0
    W

    Hey guys. This is my JS solution. Anyone know why I got this error? Really appreciated your help.

    0_1478748761169_屏幕快照 2016-11-09 9.32.17 PM.png

    var findAnagrams = function(s, p) {
        var res = [];
        var len = p.length;
        for(var i=0;i<s.length;i++){
            var t = s.slice(i,i+len).split('').sort().join(''); 
            if(t === p)res.push(i);
        }
        return res;
    };
    

  • 0
    A

    @wkudos p not sort


Log in to reply
 

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