Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashSet;
- struct Solution {}
- impl Solution {
- pub fn contains_duplicate(nums: Vec<i32>) -> bool {
- let mut set = HashSet::new();
- for num in nums {
- if !set.insert(num) {
- return true;
- }
- }
- false
- }
- }
- fn main() {
- println!("{}", Solution::contains_duplicate(vec![1,2,3,4,1]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement