Contains Duplicate
思路一: Set 检测
public static boolean containsDuplicate(int[] nums) {
Set<Integer> set = new HashSet<>();
for (int num : nums) {
if (set.contains(num)) {
return true;
}
set.add(num);
}
return false;
}
标签:217,set,return,int,num,easy,leetcode
From: https://www.cnblogs.com/iyiluo/p/16804875.html