1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
fn main() { println!("Hello, world!"); } struct Solution {} impl Solution { pub fn find_duplicate(nums: Vec<i32>) -> i32 { for i in 0..nums.len()-1 { if nums[i+1..nums.len()].contains(&nums[i]) { return nums[i]; } } 0 } }