leetcodedaybyday -Beats 61.63% with Python3 and Beats 30.29% with C++ 
IntuitionThe goal is to identify elements that are present in all subarrays of the 2D list nums. By counting the occurrences of elements in each subarray and ch
# Intuition
The goal is to identify elements that are present in all subarrays of the 2D list `nums`. By counting the occurrences of elements in each subarray and checking if they appear in all subarrays, we can efficiently solve the problem.

# Approach
1. **Frequency Counting**:
   - Use a hash map or dictionary to count the occurrences of each element across all subarrays.
   - Ensure each element is counted only once per subarray by using a `set` for each subarray.

2. **Filter Common Elements**:
   - After populating the hash map, select elements that appear exactly as many times as the number of subarrays. These are the common elements.

3. **Sort the Result**:
   - Return the sorted list of common elements.

# Complexity
- **Time Complexity**:
  - Let `N` be the total number of elements across all subarrays and `K` the size of the result:
    - Counting occurrences: `O(N)`.
    - Sorting the result: `O(K * log(K))`.
  - **Overall**: `O(N + K * log(K))`.

- **Space Complexity**:
  - `O(U)`, where `U` is the total number of unique elements across all subarrays, used for the hash map.

# Code
```python3 []
class Solution:
    def intersection(self, nums: List[List[int]]) -> List[int]:
        counts = defaultdict(int)
        i = 0
        my_set = set()
        while i < len(nums):
            k = 0
            for k in nums[i]:
                counts[k] += 1
            i += 1
        for key, value in counts.items():
            if value == len(nums):
                my_set.add(key)
        ans = sorted(my_set)
        return ans


        
```
```cpp []
class Solution {
public:
    vector<int> intersection(vector<vector<int>>& nums) {
        int n = nums.size();
        map<int, int> count;
        vector<int> matrix;
        for (int i = 0; i < n; i++){
            for (int j = 0; j < nums[i].size(); j++){
                count[nums[i][j]]++;
            }
        }
        for (auto idx : count)
            if (idx.second == n)
                matrix.push_back(idx.first);
        return matrix;
    }
};
```

['C++', 'Python3']