feat: add initial implementation of Cargo.toml, Cargo.lock, and lib.rs with num_identical_pairs function
This commit is contained in:
parent
45adae9f25
commit
45ad6c31b4
7
1512_number_of_good_pairs/Cargo.lock
generated
Normal file
7
1512_number_of_good_pairs/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "number_of_good_pairs"
|
||||
version = "0.1.0"
|
6
1512_number_of_good_pairs/Cargo.toml
Normal file
6
1512_number_of_good_pairs/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "number_of_good_pairs"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
17
1512_number_of_good_pairs/src/lib.rs
Normal file
17
1512_number_of_good_pairs/src/lib.rs
Normal file
@ -0,0 +1,17 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn num_identical_pairs(nums: Vec<i32>) -> i32 {
|
||||
let mut result = 0;
|
||||
|
||||
for i in 0..nums.len() {
|
||||
for j in (i + 1)..nums.len() {
|
||||
if nums[i] == nums[j] {
|
||||
result += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user