Given an array of integers nums, return the number of good pairs.

A pair (i, j) is called good if nums[i] == nums[j] and i &lt; j.

&nbsp;
Example 1:

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.


Example 2:

Input: nums = [1,1,1,1]
Output: 6
Explanation: Each pair in the array are good.


Example 3:

Input: nums = [1,2,3]
Output: 0


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 100
	1 &lt;= nums[i] &lt;= 100


from itertools import combinations
class Solution:
    def numIdenticalPairs(self, nums) -> int:
        res = 0
		nums_set = set(nums)
        nums_coppy = nums
        for number in nums_set:
            number_found = []
            deleted = 0
            while True:
                try:
                    found = nums_coppy.index(number)
                    nums_coppy.remove(number)
                    if deleted > 0:
                        number_found.append(found + deleted)
                    else:
                        number_found.append(found + deleted)
                    deleted += 1
                except:
                    comb = list(combinations(number_found, 2))
                    res += len(comb)
                    break
        return res
class Solution {
    public int numIdenticalPairs(int[] nums) {
        int len =nums.length;
        int counter=0;
        for (int i =0;i<len;i++){
            for (int j=i+1;j<len;j++){
                if(nums[i]==nums[j]){
                    counter++; 
                }           
            }
            
        }
        return counter;
        
    }
}
class Solution {
public:
    int numIdenticalPairs(vector<int>& nums) {

        int cnt = 0;
        for(int i=0 ; i<nums.size() ; i++){
            for(int j=i+1 ; j<nums.size() ; j++){
                if(nums[i] == nums[j]){
                    cnt++;
                }
            }
        }

        return cnt;
    }
};
var numIdenticalPairs = function(nums) {
    let counter = 0;
    let map = {};
    for(let num of nums) {
        if(map[num]) {
            counter += map[num];
            map[num]++;
        } else {
            map[num] = 1;
        }
    }
    return counter;
};
Number of Good Pairs