Skip to content

Commit 628475f

Browse files
authored
Create 2176. Count Equal and Divisible Pairs in an Array
1 parent ec2ea7c commit 628475f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Diff for: 2176. Count Equal and Divisible Pairs in an Array

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public:
3+
int countPairs(vector<int>& nums, int k) {
4+
int ans = 0;
5+
for (int i = 0; i < nums.size(); i++) {
6+
for (int j = i + 1; j < nums.size(); j++) {
7+
if (nums[i] == nums[j] && (i * j) % k == 0) {
8+
ans++;
9+
}
10+
}
11+
}
12+
return ans;
13+
}
14+
};

0 commit comments

Comments
 (0)