Simple JavaScript Solution but Time Limit Exceeded


  • 0
    S

    I think it is a very good solution but it turns out Time Limit Exceeded
    Anybody knows why?

    /**
     * @param {number[]} nums
     * @return {boolean}
     */
    var containsDuplicate = function(nums) {
        return nums.some(function(elem, idx){
            return nums.indexOf(elem) !== idx;
        });
    };
    

Log in to reply
 

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