HTMLify

LeetCode - Number of Good Pairs - Rust
Views: 241 | Author: abh
impl Solution {
    pub fn num_identical_pairs(nums: Vec<i32>) -> i32 {
        let mut count = 0;
        for i in 0..nums.len(){
            for j in i+1..nums.len(){
                if (nums[i] == nums[j]){
                    count += 1;
                }
            }
        }
        return count;
    }
}

Comments

abh 2023-10-08 05:21

This was my first rust program, It run in firat try and also answer accepted :)