Easy to Understand Java Code || Beats 100%
Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n\nclass Solution {\n    public int[] findIntersectionValues(int[] nums1, int[] nums2) {
# Complexity\n- Time complexity:\nO(n)\n- Space complexity:\nO(n)\n# Code\n```\nclass Solution {\n    public int[] findIntersectionValues(int[] nums1, int[] nums2) {\n        int[] res = new int[2];\n        HashSet<Integer> set1 = new HashSet<>();\n        HashSet<Integer> set2 = new HashSet<>();\n\n        for(int num : nums1){\n            set1.add(num);\n        }\n\n        for(int num : nums2){\n            set2.add(num);\n        }\n\n        for(int num : nums1){\n            res[0] += set2.contains(num) ? 1 : 0;\n        }\n\n        for(int num : nums2){\n            res[1] += set1.contains(num) ? 1 : 0;\n        }\n        return res;\n    }\n}\n```
['Java']