JS Time Limit Exceeded on TestCase 33/34

  • 0

    Hey guys, quick JS question on TLE - not quite sure how to reduce the time on this, I feel like I have exhausted almost all options. Any help would be super appreciated! Thanks so much in advance :)

    var findAnagrams = function(s, p) {
        var arr = s.split("");
        var tester = p.split("").sort();
        var len = tester.length;
        var results = [];
        var goto = arr.length-len
            if(tester.indexOf(arr[i])!== -1 && arr.slice(i,len+i).sort().join("")==tester.join("")){ results.push(i) }
        return results;

Log in to reply

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