# Leetcode 217. Contains Duplicate ###### tags: `Leetcode(C++)` 題目 : https://leetcode.com/problems/contains-duplicate/ 想法 : 用MAP做,時間複雜度爆炸了,但還是AC ? . ? 時間複雜度 : O(nlogn)。 程式碼 : ``` class Solution { public: bool containsDuplicate(vector<int>& nums) { bool ok = 0; int l = nums.size(); map<int,int> m; for(int i = 0 ; i < l ; i++){ m[nums[i]]++; } map<int,int>::iterator it; for(it = m.begin() ; it != m.end() && !ok ; it++){ //cout << it -> second << " "; if(it -> second >= 2) ok = 1; } return ok; } }; ```