Count frequency using array
Intuition\n- As the value of each item is very small ( <= 100), use array to count each item frequency.\n\n# Approach\n- count frequency of each item in each ar
# Intuition\n- As the value of each item is very small ( <= 100), use array to count each item frequency.\n\n# Approach\n- count frequency of each item in each array in freq1 & freq2 array.\n- Then check the freq array from 1 to 100 and see if the freq2[i] is more than 0 or not. If its more than zero then add the freq1[i] to the res1 and similarly check freq1[i] != 0 && if so add freq2[i] to the res2.\n\n\n# Complexity\n- Time complexity: O(N)\n\n- Space complexity: O(N)\n\n# Code\n```\nvector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n    vector<int> freq1(101, 0), freq2(101,0);\n    int res1 = 0, res2 = 0;\n    for(auto n: nums1) freq1[n]++;\n    for(auto n: nums2) freq2[n]++;\n    for(int i = 1; i <= 100; ++i) {\n        if(freq2[i]) res1 += freq1[i];\n        if(freq1[i]) res2 += freq2[i]; \n    }\n    return {res1, res2};\n}\n```\n\n\n---\n\n\n<b>Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n---
['C++']