leetcode 217. Contains Duplicate
class Solution {
public boolean containsDuplicate(int[] nums) {
Set<Integer> s = new HashSet<Integer>();
for (int val: nums) {
if (!s.add(val)) return true;
}
return false;
}
}
浙公网安备 33010602011771号