Input: nums = [1,2,3,1,1,3]
Output: 4
Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
Input: nums = [1,1,1,1]
Output: 6
Explanation: Each pair in the array are good.
Input: nums = [1,2,3]
Output: 0
class Solution {
public:
int numIdenticalPairs(vector<int>& nums)
{
size_t counter = 0;
for(auto iter = nums.begin(); iter != nums.end(); ++iter)
counter += std::count(std::next(iter), nums.end(), *iter);
return counter;
}
};