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;
    }
}
posted on 2019-04-07 22:51  王 帅  阅读(77)  评论(0编辑  收藏  举报