Number of Good Pairs LeetCode solution in C++

1
class Solution {
2
public:
3
int numIdenticalPairs(vector<int> &nums) {
4
int cnt = 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]) {
8
cnt++;
9
}
10
}
11
}
12

13
return cnt;
14
}
15
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0