Skip to content

Commit fb1c065

Browse files
authored
Added solution for 2176
1 parent a9c409f commit fb1c065

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
impl Solution {
2+
// Create loop within a loop that checks if nums values at both positions are correct and that their product is divisible by k. Return the result at the end
3+
pub fn count_pairs(nums: Vec<i32>, k: i32) -> i32 {
4+
let mut i = 0;
5+
let mut j = 0;
6+
let len = nums.len();
7+
let mut result = 0;
8+
9+
while i < len {
10+
for j in (i + 1)..len {
11+
if (nums[i] == nums[j]) && ((i * j) % (k as usize) == 0) {
12+
result += 1;
13+
}
14+
}
15+
i += 1;
16+
}
17+
return result;
18+
}
19+
}

0 commit comments

Comments
 (0)