1
Fork 0
leetcode/source/contains_duplicate/mod.rs

9 lines
307 B
Rust
Raw Permalink Normal View History

2022-04-11 11:23:20 +00:00
pub fn contains_duplicate(numbers: Vec<i32>) -> bool {
// Uncomment FromIterator in Leetcode since they're using Rust Edition 2018.
// Edition 2021 has this trait in its prelude.
// use std::iter::FromIterator;
std::collections::HashSet::<_>::from_iter(numbers.iter()).len()
!= numbers.len()
}