Two Pointer Approch Using HashMap | 100%Beats
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(n2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    private int countways(int[] nums1, int []nums2){\n        int count = 0;\n        Map<Long, Integer> map = new HashMap<>();\n        for (int n : nums2) {\n            map.put((long) n * n, map.getOrDefault((long) n * n, 0) + 1);\n        }\n\n        for (int i = 0; i < nums1.length; i++) {\n            for (int j = i + 1; j < nums1.length; j++) {\n                long prod = (long) nums1[i] * (long) nums1[j];\n                \n                if (map.containsKey(prod)) count += map.get(prod);\n            }\n        }\n        return count;\n    }\n\n\n    public int numTriplets(int[] nums1, int[] nums2) {\n        Arrays.sort(nums1);\n        Arrays.sort(nums2);\n        \n        return countways(nums1, nums2)+countways(nums2, nums1);\n    }\n}\n```
['Array', 'Hash Table', 'Math', 'Two Pointers', 'Java']