You are given a 0-indexed integer array nums. In one operation, you may do the following:


	Choose two integers in nums that are equal.
	Remove both integers from nums, forming a pair.


The operation is done on nums as many times as possible.

Return a 0-indexed integer array answer of size 2 where answer[0] is the number of pairs that are formed and answer[1] is the number of leftover integers in nums after doing the operation as many times as possible.

&nbsp;
Example 1:

Input: nums = [1,3,2,1,3,2,2]
Output: [3,1]
Explanation:
Form a pair with nums[0] and nums[3] and remove them from nums. Now, nums = [3,2,3,2,2].
Form a pair with nums[0] and nums[2] and remove them from nums. Now, nums = [2,2,2].
Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [2].
No more pairs can be formed. A total of 3 pairs have been formed, and there is 1 number leftover in nums.


Example 2:

Input: nums = [1,1]
Output: [1,0]
Explanation: Form a pair with nums[0] and nums[1] and remove them from nums. Now, nums = [].
No more pairs can be formed. A total of 1 pair has been formed, and there are 0 numbers leftover in nums.


Example 3:

Input: nums = [0]
Output: [0,1]
Explanation: No pairs can be formed, and there is 1 number leftover in nums.


&nbsp;
Constraints:


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


class Solution:
    def numberOfPairs(self, nums: List[int]) -> List[int]:
        ans = [0] * 2
        c = Counter(nums)
        
        for v in c.values():
            ans[0] += (v // 2)
            ans[1] += (v % 2)
        
        return ans
class Solution {
    public int[] numberOfPairs(int[] nums) {

        if(nums.length == 1)
        return new int[]{0,1};

        HashSet<Integer> set = new HashSet<>();

        int pairs=0;
        for(int i : nums){
            if(!set.contains(i)){
               set.add(i); // No pair present
            }else{
              set.remove(i); // Pair found
              pairs++;
            }
        }

        return new int[]{pairs,set.size()};
    }
}
class Solution {
public:
	//store the frequency of each of the number in the map and
	//then return the answer as sum all the values dividing 2 and 
	//sum all by taking reminder of 2
    vector<int> numberOfPairs(vector<int>& nums) {
        unordered_map<int, int> mp;
        for(auto i: nums) mp[i]++;
        int c1 = 0, c2 = 0;
        for(auto m: mp){
            c1 += m.second/2;
            c2 += m.second%2;
        }
        return {c1, c2};
    }
};
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var numberOfPairs = function(nums) {
  let pairs = 0;
  const s = new Set();
  for (const num of nums) {
    if (s.has(num)) {
      pairs += 1;
      s.delete(num);
    } else {
      s.add(num);
    }
  }
  return [pairs, nums.length - pairs * 2];
};
Maximum Number of Pairs in Array