Javascript solution (Beats 88%)


  • 0
    R
    var containsDuplicate = function(nums) {
        var hash = {},
            size = nums.length,
            actual,
            i = 0,
            result = false;
        
        while(i < size){
            actual = nums[i++];
            if(actual in hash)
                return true;
            hash[actual] = 1;
        }
        
        return result;
    };

Log in to reply
 

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