Skip to content

Commit 6e6141d

Browse files
committed
[1week]Contains Duplicate Sold
1 parent 0fc7ec8 commit 6e6141d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

contains-duplicate/Hong-Study.cpp

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

0 commit comments

Comments
 (0)