1.Contains Duplicate

1.Contains Duplicate

·

1 min read

Table of contents

Leet code question

  1.  Example 1:
    
     Input: nums = [1,2,3,1]
     Output: true
     Example 2:
    
     Input: nums = [1,2,3,4]
     Output: false
     Example 3:
     // code 
     function containsDuplicate(nums){
       // creating set using nums
        const isDuplicate=new Set(nums);
       // checking if created set and nums length are eqaul
        if(isDuplicate.size===nums.length){
         return false;
        }
        return true;
     }