leet-code/contains-duplicate/sol.rs

8 lines
204 B
Rust
Raw Normal View History

2022-05-29 19:21:38 +00:00
use std::collections::HashSet;
impl Solution {
pub fn contains_duplicate(nums: Vec<i32>) -> bool {
let mut exists = HashSet::new();
!nums.into_iter().all(|n| exists.insert(n))
}
}