Skip to content

Commit 0b9d90f

Browse files
committed
contains-duplicate
1 parent 53ce7c7 commit 0b9d90f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

contains-duplicate/DaleSeo.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
use std::collections::HashSet;
2+
3+
// TC: O(n)
4+
// SC: O(n)
5+
impl Solution {
6+
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
7+
let mut set = HashSet::new();
8+
!nums.into_iter().all(|num| set.insert(num))
9+
}
10+
}

0 commit comments

Comments
 (0)