Given a 2D integer array nums where nums[i] is a non-empty array of distinct positive integers, return the list of integers that are present in each array of nums sorted in ascending order.
&nbsp;
Example 1:

Input: nums = [[3,1,2,4,5],[1,2,3,4],[3,4,5,6]]
Output: [3,4]
Explanation: 
The only integers present in each of nums[0] = [3,1,2,4,5], nums[1] = [1,2,3,4], and nums[2] = [3,4,5,6] are 3 and 4, so we return [3,4].

Example 2:

Input: nums = [[1,2,3],[4,5,6]]
Output: []
Explanation: 
There does not exist any integer present both in nums[0] and nums[1], so we return an empty list [].


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 1000
	1 &lt;= sum(nums[i].length) &lt;= 1000
	1 &lt;= nums[i][j] &lt;= 1000
	All the values of nums[i] are unique.


class Solution:
    def intersection(self, A: List[List[int]]) -> List[int]:
        return sorted([k for k,v in Counter([x for l in A for x in l]).items() if v==len(A)])
		
class Solution {
    public List<Integer> intersection(int[][] nums) {

        List<Integer> ans = new ArrayList<>();

        int[] count = new int[1001];

        for(int[] arr : nums){
            for(int i : arr){
                count[i]++;
            }
        }

       for(int i=0;i<count.length;i++){
           if(count[i]==nums.length){
               ans.add(i);
           }
       }

        return ans;
    }
}
class Solution {
public:
    vector<int> intersection(vector<vector<int>>& nums) {
        int n = nums.size(); // gives the no. of rows
        map<int,int> mp; // we don't need unordered_map because we need the elements to be in sorted format.
        vector<int> vec;
        
        // traverse through the 2D array and store the frequency of each element
        for(int row=0;row<n;row++)
        {
            for(int col=0;col<nums[row].size();col++)
            {
                mp[nums[row][col]]++;
            }
        }
        
        // In the 2D array, intersection occurs when the elements are present in every row.
        // So the frequency of the element should match with the no. or rows in the 2D array.
        for(auto element : mp)
            if(element.second == n)
                vec.push_back(element.first);
        
        // return the intersecting elements
        return vec;
    }
};
var intersection = function(nums) {
    let set = addToSet(nums[0]);
    for(let i=1; i<nums.length; i++) {
        let tempSet = addToSet(nums[i]);
        for(let key of set) {
            if( !tempSet.has(key) )
                set.delete(key);
        }
    }
    return [...set].sort( (a,b) => a-b );
};

function addToSet(arr) {
    let set = new Set(arr);
    return set;
}
Intersection of Multiple Arrays