This is my solution. 18ms Java Solution


  • 0
    1
     public boolean containsDuplicate(int[] nums) {
            HashSet<Integer> hashSet = new HashSet<>();
            for (int i = 0; i < nums.length; i++) {
                hashSet.add(nums[i]);
            }
            if (hashSet.size() != nums.length) {
                return true;
            } else {
                return false;
            }
        }
    

Log in to reply
 

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