Skip to content

Commit 2d7b556

Browse files
committed
Sync LeetCode submission - Contains Duplicate (rust)
1 parent 917987a commit 2d7b556

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
use std::collections::HashSet;
2+
impl Solution {
3+
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
4+
let mut set = HashSet::new();
5+
6+
for num in nums.into_iter() {
7+
if !set.insert(num) {
8+
return true;
9+
}
10+
}
11+
return false;
12+
}
13+
}

0 commit comments

Comments
 (0)