5 LINE JAVA SOLUTION USING HASHMAP WITH EXPLANATION
1. Store the value of num1*num1 from the first Array in a map.\n2. Using two for loops generate all possible combination of num2 and check if the set contains t
**1. Store the value of num1*num1 from the first Array in a map.\n2. Using two for loops generate all possible combination of num2 and check if the set contains those value.\n3. If it contains add it to the sum and return it.**\n```\npublic int calculate(int[] num1, int[] num2) {\n        HashMap<Long, Integer> map = new HashMap<>();\n        long n = num1.length,  m = num2.length, ans = 0;\n        for(int i=0; i<n; i++) map.put((long)num1[i]*num1[i],map.getOrDefault((long)num1[i]*num1[i],0)+1);\n        for(int j=0; j<m; j++)  for(int k=j+1; k<m; k++)   ans += (long)map.getOrDefault((long)num2[j]*num2[k],0);\n        return (int)ans;\n    }\n    public int numTriplets(int[] nums1, int[] nums2) {\n        return calculate(nums1,nums2) + calculate(nums2,nums1);\n    }\n```
['Java']