@@ -0,0 +1,650 @@
+package com.pengyifan.leetcode;%0A%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A/**%0A * Given an array of integers, find if the array contains any duplicates. Your function should%0A * return true if any value appears at least twice in the array, and it should return false if every%0A * element is distinct.%0A */%0Apublic class ContainsDuplicate %7B%0A  public boolean containsDuplicate(int%5B%5D nums) %7B%0A    if (nums == null %7C%7C nums.length == 0) %7B%0A      return false;%0A    %7D%0A    Set%3CInteger%3E set = new HashSet%3C%3E();%0A    for (int i : nums) %7B%0A      if (set.contains(i)) %7B%0A        return true;%0A      %7D else %7B%0A        set.add(i);%0A      %7D%0A    %7D%0A    return false;%0A  %7D%0A%7D%0A

contains duplicate