Skip to content

Commit df6717c

Browse files
committed
contains-duplicate
1 parent a635756 commit df6717c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

contains-duplicate/livemehere.rs

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

0 commit comments

Comments
 (0)