Skip to content

Commit 10aaefc

Browse files
PDKhanriver20s
authored andcommitted
contains-duplicate solution
1 parent c9399f5 commit 10aaefc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

contains-duplicate/PDKhan.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public:
3+
bool containsDuplicate(vector<int>& nums) {
4+
unordered_map<int, int> map;
5+
6+
for(int i = 0; i < nums.size(); i++){
7+
map[nums[i]]++;
8+
9+
if(map[nums[i]] == 2)
10+
return true;
11+
}
12+
13+
return false;
14+
}
15+
};

0 commit comments

Comments
 (0)