Simple JAVA Solution using HashSet||⭐⭐⭐
\n# Complexity\n- Time complexity: O(max(n,m))\n\n- Space complexity:O(n+m);\n# Code\n\nclass Solution {\n    public int[] findIntersectionValues(int[] nums1, i
\n# Complexity\n- Time complexity: O(max(n,m))\n\n- Space complexity:O(n+m);\n# Code\n```\nclass Solution {\n    public int[] findIntersectionValues(int[] nums1, int[] nums2) {\n         \n        HashSet<Integer> hs1 = new HashSet<>();\n        HashSet<Integer> hs2 = new HashSet<>();\n        \n        for(int i=0;i<nums1.length;i++) hs1.add(nums1[i]);\n        for(int i=0;i<nums2.length;i++) hs2.add(nums2[i]);\n        \n        int ans[]= new int[2];\n       \n        int count=0;\n        for(int i=0;i<nums1.length;i++)\n        {\n           if(hs2.contains(nums1[i])) count++;  \n        }\n        ans[0]=count;\n        count=0;\n        \n        for(int i=0;i<nums2.length;i++)\n        {\n           if(hs1.contains(nums2[i])) count++;  \n        }\n        ans[1]=count;\n        return ans;\n        \n        \n    }\n}\n```
['Hash Table', 'Java']