Intuitive Javascript Solution

  • 0
    var containsDuplicate = function(nums) {
        // duplicate numbers locate side by side in sorted array
        for (const [i, n] of nums.entries())
            if (i > 0 && n === nums[i-1]) return true;
        return false;

Log in to reply

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