@@ -0,0 +1,894 @@
+/** %0A *%09Given an array of integers, find if the array contains any duplicates. %0A *%09Your function should return true if any value appears at least twice in the array, %0A *%09and it should return false if every element is distinct.%0A *%0A *%09Author: matao%0A *%0A */%0A%0Aimport java.util.Map;%0Aimport java.util.HashMap;%0A%0Apublic class ContainsDuplicate %7B%0A%09public static boolean containsDuplicate(int%5B%5D nums) %7B%0A%09%09if(nums == null %7C%7C nums.length == 0) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%0A%09%09Map%3CInteger, Integer%3E map = new HashMap%3CInteger, Integer%3E();%0A%09%09for (int i = 0; i %3C nums.length; i++) %7B%0A%09%09%09if(map.containsKey(nums%5Bi%5D)) %7B%0A%09%09%09%09return true;%0A%09%09%09%7D%09%0A%09%09%09map.put(nums%5Bi%5D, nums%5Bi%5D);%0A%09%09%7D%0A%09%09return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A    %09int%5B%5D nums1 = %7B1, 2, 3, 3%7D;%0A    %09int%5B%5D nums2 = %7B1, 3, 5, 6%7D;%0A    %09System.out.println(containsDuplicate(nums1));%0A    %09System.out.println(containsDuplicate(nums2));%0A    %7D%0A%7D

add Contains Duplicate solution