LeetCode-217 Posted on 2020-12-13 Edited on 2025-02-13 In LeetCode 题目 结果 代码1234567891011class Solution { public boolean containsDuplicate(int[] nums) { Set<Integer> set = new HashSet<>(); for (int num : nums) { if (!set.add(num)) { return true; } } return false; }} 复杂度时间复杂度:O(n) 空间复杂度:O(n)