Java Solution with HashSet 396ms


  • 0
    G
    public class Solution {
    public boolean containsDuplicate(int[] nums) {
        Set<Integer> intSet = new HashSet<Integer>();
        for(int i : nums){ intSet.add(nums[i]); }
        return intSet.size() < nums.length? true:false;
    }
    

    }


Log in to reply
 

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