---
# System prepended metadata

title: \#217 Contains Duplicate
tags: [leetcode, leetcode-easy]

---

# \#217 Contains Duplicate
## *判斷一陣列內是否有重複的元素*
## Log
 - build 20210430 by syhuang

## 初見
 - map解法, 初見即畢業
```javascript=
var containsDuplicate = function(nums) {
    var map = {};
    for(var n of nums){
        if(typeof(map[n])!='undefined') return true;
        map[n] = n;
    }
    return false;
};
```
## 備註
 - [Set解法與排序解法(效率較差)](https://leetcode.com/problems/contains-duplicate/discuss/60872/1-line-JavaScript-solutions)
## 參考
###### tags: `leetcode`, `leetcode-easy`