Java solution
\nclass Solution {\n    public int numTriplets(int[] nums1, int[] nums2) {\n       return res(nums1,nums2)+res(nums2,nums1);\n    }\n    public static int res(i
```\nclass Solution {\n    public int numTriplets(int[] nums1, int[] nums2) {\n       return res(nums1,nums2)+res(nums2,nums1);\n    }\n    public static int res(int[] nums1,int[] nums2)\n    {\n        int count=0;\n\t\tHashMap<Long,Integer> map=new HashMap<Long,Integer>();\n\t\tfor(long i:nums1)\n\t\t\tmap.put((i*i), map.getOrDefault(i*i,0)+1);\n\t\tfor(int i=0;i<nums2.length-1;i++)\n\t\t{\n\t\t\tfor(int j=i+1;j<nums2.length;j++)\n\t\t\t{\n\t\t\t\tlong prod=(long)nums2[i]*nums2[j];\n\t\t\t\tif(map.containsKey(prod))\n\t\t\t\t{\n\t\t\t\t\tcount=count+map.get(prod);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn count;\n    }\n}\n```
['Java']