leet-code/contains-duplicate/sol.rs

8 lines
204 B
Rust

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))
}
}