summaryrefslogtreecommitdiff
path: root/find-the-duplicate-number/src/main.rs
blob: c86c542260d120e1a25fd8e248d5e7792b35e1a4 (plain)
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
    }
}