One unordered_map
IntuitionTo determine the intersection values between two arrays, we need to efficiently check for common elements and count their occurrences. Using a hash map
# Intuition
To determine the intersection values between two arrays, we need to efficiently check for common elements and count their occurrences. Using a hash map allows us to quickly look up values and maintain frequency counts.

# Approach
1. Use an unordered map (`freq`) to store the frequency of each element in `nums1`.
2. Iterate through `nums2` and check if each element exists in the map.
3. If an element from `nums2` is found in `nums1`:
   - Increase `count2` since the element is common.
   - Add the frequency count from `nums1` to `count1`.
   - Set its frequency to zero to ensure it is only counted once for `count1`.
4. Return `{count1, count2}` as the final result.

```cpp
#include <vector>
#include <unordered_set>
using namespace std;

class Solution {
public:
    vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {
        unordered_map<int, int> freq;
        for (int num : nums1) {
            freq[num]++;
        }
        
        int count1 = 0, count2 = 0;
        for (int num : nums2) {
            if (freq.count(num)) {
                count2++;
                count1 += freq[num];
                freq[num] = 0; // Ensure we only count for count1 once per unique num
            }
        }
        
        return {count1, count2};
    }
};
['C++']