✅ One Solution if elements in arrays are => { DISTINCT or DUPLICATE }
Similar Question: 2032. Two Out of Three\n\nExplanation:\nJust Resisit the increase of count of same elements multiple times in an array.\n\nFot this We use: pa
**Similar Question**: [2032. Two Out of Three](https://leetcode.com/contest/weekly-contest-262/problems/two-out-of-three/)\n\n**Explanation:**\nJust Resisit the increase of count of same elements multiple times in an array.\n\n**Fot this We use**: `pair<int,int>`\n`First int`- Count of arrays in which we have seen this element\n`Second int` - Array number in which it was last found. **{This will help in preventing from increase in count of same element muliple times in a single array}**\n\n> This Solution will also work if elements across the arrays are not distinct.  **[BOTH TYPES USES SAME SPACE i.e if all are {distinct or not-distinct}]**\n\n**Type A**\nWe simply use a `map` and return the answer as map gives a `sorted sequence`.\n**Runtime - 24ms**\n# C++\n \n    vector<int> intersection(vector<vector<int>>& nums) {\n        map<int,pair<int,int>> mp; \n        int cnt=1;\n        for(auto i:nums){\n\t\t    for(auto j:i) if(mp[j].second!=cnt) mp[j].first++, mp[j].second=cnt;\n\t\t    cnt++;\n\t    }\n        vector<int> res;\n        for(auto i:mp) if(i.second.first==size(nums)) res.push_back(i.first);\n        return res;\n    }\n\t\n**Type B**\nWe simply use a `unordered_map` and return the answer after `sorting manually`.\n**Runtime - 7ms**\n# C++\n    vector<int> intersection(vector<vector<int>>& nums) {\n        unordered_map<int,pair<int,int>> mp; \n        int cnt=1;\n        for(auto i:nums){\n\t        for(auto j:i) if(mp[j].second!=cnt) mp[j].first++, mp[j].second=cnt;\n\t        cnt++;\n        }\n        vector<int> res;\n        for(auto i:mp) if(i.second.first==size(nums)) res.push_back(i.first);\n        sort(begin(res),end(res));\n        return res;  \n    }\n\n
['C']