Easiest [C++/Python3/C#/Python/Java ] Solutions beats 100% Only logic ...
Intuition\n\n\n\n\n\nC++ []\nclass Solution {\npublic:\n    vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<
# Intuition\n![Screenshot 2024-03-19 125528.png](https://assets.leetcode.com/users/images/9d88b6a0-7d77-4138-b203-a86730d24c27_1710833278.027597.png)\n![Screenshot 2024-03-19 125515.png](https://assets.leetcode.com/users/images/395ca112-3af6-45a2-840d-b89c4521083f_1710833283.0980022.png)\n![Screenshot 2024-03-19 125535.png](https://assets.leetcode.com/users/images/b9104fbe-eb7c-45a2-8910-89fd16d45e8e_1710833290.9814224.png)\n![Screenshot 2024-03-19 125543.png](https://assets.leetcode.com/users/images/b20645c7-bc88-464c-a19c-7300ec267c24_1710833296.549831.png)\n![Screenshot 2024-03-19 125552.png](https://assets.leetcode.com/users/images/d4837335-efa6-4bbc-acd6-a3d3725733ca_1710833301.505721.png)\n```C++ []\nclass Solution {\npublic:\n    vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int> set1(nums1.begin(), nums1.end());\n        unordered_set<int> set2(nums2.begin(), nums2.end());\n        int count1 = 0, count2 = 0;\n        for (auto& num : nums1)\n            count1 += set2.count(num);\n        for (auto& num : nums2)\n            count2 += set1.count(num);\n        return {count1, count2};\n    }\n};\n```\n```python3 []\nclass Solution:\n    def findIntersectionValues(self, nums1: List[int], nums2: List[int]) -> List[int]:\n        set1 = set(nums1)\n        set2 = set(nums2)\n\n        first = 0\n        for num in nums1:\n            if num in set2:\n                first += 1\n        \n        second = 0 \n        for num in nums2:\n            if num in set1:\n                second += 1\n        \n\n        return [first, second]\n```\n```C# []\npublic class Solution\n{\n    public int[] FindIntersectionValues(int[] nums1, int[] nums2)\n    {\n        var set1 = new HashSet<int>(nums1);\n        var set2 = new HashSet<int>(nums2);\n        return new[] {nums1.Count(x => set2.Contains(x)), nums2.Count(x => set1.Contains(x))};\n    }\n}\n```\n```Java []\nclass Solution {\n    public int[] findIntersectionValues(int[] nums1, int[] nums2) {\n        int[] res = new int[2];\n        int val1 = 0, val2 = 0;\n        for (int i = 0; i < nums1.length; ++i) {\n            for (int j = 0; j < nums2.length; j++)\n                if (nums1[i] == nums2[j]) {\n                    val1++;\n                    break;\n                }\n        }\n        for (int i = 0; i < nums2.length; ++i) {\n            for (int j = 0; j < nums1.length; j++)\n                if (nums2[i] == nums1[j]) {\n                    val2++;\n                    break;\n                }\n        }\n        res[0] = val1;\n        res[1] = val2;\n        return res;\n    }\n}\n```\n```C++ []\nclass Solution {\npublic:\n    vector<int> findIntersectionValues(vector<int>& nums1, vector<int>& nums2) {\n        vector<int> f1(101, 0);\n        vector<int> f2(101, 0);\n        for (int i = 0; i < nums1.size(); i++)\n            f1[nums1[i]]++;\n        for (int i = 0; i < nums2.size(); i++)\n            f2[nums2[i]]++;\n    \n        vector<int> result(2, 0);\n        for (int i = 1; i < 101; i++) {\n            if (f1[i] && f2[i]) {\n                result[0] += f1[i];\n                result[1] += f2[i];\n            }\n        }\n        return result;\n    }\n};\n```\n```python []\nclass Solution(object):\n    def findIntersectionValues(self, nums1, nums2):\n        """\n        :type nums1: List[int]\n        :type nums2: List[int]\n        :rtype: List[int]\n        """\n        s1 = set(nums1)\n        s2 = set(nums2)\n        cnt1 = cnt2 = 0\n        for x in nums1:\n            if x in s2:\n                cnt1 += 1\n        for y in nums2:\n            if y in s1:\n                cnt2 += 1\n        lst = [0] * 2\n        lst[0] = cnt1\n        lst[1] = cnt2\n        return lst\n```\n```C []\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* findIntersectionValues(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize) {\n    bool set1[101] = {};\n    bool set2[101] = {};\n    for (int i = 0; i < nums1Size; i++)\n        set1[nums1[i]] = true;\n    for (int i = 0; i < nums2Size; i++)\n        set2[nums2[i]] = true;\n    int* res = (int*)malloc(sizeof(int) * 2);\n    int cnt1 = 0, cnt2 = 0;\n    for (int i = 0; i < nums1Size; i++)\n        if (set2[nums1[i]] == true)\n            cnt1++;\n\n    for (int i = 0; i < nums2Size; i++)\n        if (set1[nums2[i]] == true)\n            cnt2++;\n    res[0] = cnt1;\n    res[1] = cnt2;\n    *returnSize  = 2;\n    return res;\n    free(res);\n}\n```\n\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n Approach is very simple just make two sets of nums1 & nums2 so that the duplicates removed .. Then iterate over nums1 and check if the number is present in set2 or not if present increase count by 1 ... finally resulting array of size . set the res[0] = to that count variable .. Similary take another variable cnt2 iterate over nums2 and check for every element in set1 if true increase cnt2 by 1 .. finally set res[1] = cnt2 and return result\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n    O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(101) --> O(1)\n# Code\n```\npublic class Solution\n{\n    public int[] FindIntersectionValues(int[] nums1, int[] nums2)\n    {\n        var set1 = new HashSet<int>(nums1);\n        var set2 = new HashSet<int>(nums2);\n        return new[] {nums1.Count(x => set2.Contains(x)), nums2.Count(x => set1.Contains(x))};\n    }\n}\n```\n# Please upvote if my solution helps you to solve or understand any part of the code .. Your like motivates me to do better .. Thanks \n![th.jpeg](https://assets.leetcode.com/users/images/26d2d638-dd14-4f27-829e-140b2f9f7a67_1710833557.0663633.jpeg)\n
['Array', 'Hash Table', 'C', 'Python', 'C++', 'Java', 'Python3', 'C#']