Simple and Easy JAVA Solution using HashMap
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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int numTriplets(int[] nums1, int[] nums2) {\n        int res = 0;\n        res += solve(nums1,nums2);\n        res += solve(nums2,nums1);\n        return res;\n    }\n\n    private int solve(int nums1[] , int nums2[]){\n        int n = nums1.length;\n        int m = nums2.length;\n        int res = 0;\n        Map<Long,Integer> map = new HashMap<>();\n\n        for(int i=0;i<n;i++){\n            long sqr = (long)nums1[i] * (long)nums1[i];\n            map.put(sqr,map.getOrDefault(sqr,0)+1);\n        }\n\n        for(int j=0;j<m-1;j++){\n            for(int k=j+1;k<m;k++){\n                long prod = (long)nums2[j] * (long)nums2[k];\n                if(map.containsKey(prod))\n                    res+=map.get(prod);\n            }\n        }\n        \n        return res;\n    }\n}\n```
['Java']