https://leetcode.com/problems/number-of-good-pairs/
Source
int numIdenticalPairs(vector<int>& nums) {
const int N = nums.size();
int cnt = 0;
FOR (i, N) {
const int selected = nums[i];
FOR_INC (j, i+1, N) {
if (selected == nums[j]) {
cnt++;
}
}
}
return cnt;
}