Java Simple HashSet!


  • 0

    '''
    public boolean containsDuplicate(int[] nums) {
    if(nums.length==0) return false;
    Set<Integer> set1 = new HashSet <>();
    for(int i = 0; i< nums.length;i++)
    if(!set1.add(nums[i])) return true;
    return false;
    }

    '''


Log in to reply
 

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