My solution in Java


  • 1
    D
    static boolean containsDuplicate(int[] nums) {
    		HashMap<Integer, Integer> conNums = new HashMap<>();
    		for (int i = 0; i < nums.length; i++) {
    			if (conNums.containsKey(nums[i])) {
    				return true;
    			} else {
    				conNums.put(nums[i], 0);
    			}
    		}
    		return false;
    }
    

Log in to reply
 

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