@@ -0,0 +1,995 @@
+/*%0AGiven an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is distinct. %0A*/%0A%0Aimport java.io.*;%0Aimport java.util.*;%0A%0Apublic class ContainsDuplicate %7B%0A%09public static boolean containsDuplicate(int%5B%5D nums) %7B%0A        if(nums.length %3C= 0) return false;%0A        HashSet%3CInteger%3E hp = new HashSet%3CInteger%3E();%0A        for(int i=0; i %3C nums.length; i++)%7B%0A            if(!hp.add(nums%5Bi%5D)) return true;%0A        %7D%0A        return false;%0A    %7D%0A%0A%09public static void dispAr(int%5B%5D nums) %7B%0A        for(int i = 0;i %3C nums.length; i++)%7B%0A%09%09%09System.out.print(nums%5Bi%5D + %22 %22);%0A%09%09%7D%0A%09%09System.out.println();%0A        return;%0A    %7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09int%5B%5D nums = new int%5B%5D%7B1, 2, 5, 8, 7, 3, 2, 0%7D;%0A%09%09boolean res = containsDuplicate(nums);%0A%0A%09%09System.out.println(%22array:%22);%0A%09%09dispAr(nums);%0A%09%09System.out.println(%22contains duplicate? %22 + res);%0A%09%09return;%0A%09%7D%09%0A%7D%0A

contains duplicate