Contains Duplicate

来源:互联网 发布:声级计软件 编辑:程序博客网 时间:2024/04/30 12:59


public class Solution {    public boolean containsDuplicate(int[] nums) {        if (nums == null || nums.length < 1) {            return false;        }        HashSet<Integer> set = new HashSet<Integer>();        for (int num : nums) {            if (set.contains(num)) {                return true;            } else {                set.add(num);            }        }        return false;    }}


0 0