> For the complete documentation index, see [llms.txt](https://liuyang89116.gitbook.io/my-leetcode-book/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://liuyang89116.gitbook.io/my-leetcode-book/post_chapter_3_array/problem_217_contains_duplicate.md).

# Problem 217: Contains Duplicate

> <https://leetcode.com/problems/contains-duplicate/>

## 思路

* hashset 的一道题，没啥好说的，直接实现

```java
public class Solution {
    public boolean containsDuplicate(int[] nums) {
        HashSet<Integer> hs = new HashSet<Integer>();
        for (Integer i : nums) {
            if (hs.contains(i)) {
                return true;
            } else {
                hs.add(i);
            }
        }

        return false;
    }
}
```
