Java Solution Using HashMap
Attention: Need to change type to Long\n\nclass Solution {\n    public int numTriplets(int[] nums1, int[] nums2) {\n        int re=0;\n        Map<Long,Integer>
Attention: Need to change type to Long\n```\nclass Solution {\n    public int numTriplets(int[] nums1, int[] nums2) {\n        int re=0;\n        Map<Long,Integer> map=new HashMap<>();\n        for(int i:nums1){\n            long l=(long)i*(long)i;\n            int count=map.getOrDefault(l,0);\n            map.put(l,count+1);\n        }\n        for(int i=0;i<nums2.length;i++){\n            for(int j=i+1;j<nums2.length;j++){\n                long p=(long)nums2[i]*(long)nums2[j];\n                if(map.getOrDefault(p,0)>0){\n                    re+=map.get(p);\n                }\n            }\n        }\n        Map<Long,Integer> map2=new HashMap<>();\n        for(int i:nums2){\n            long l=(long)i*(long)i;\n            int count=map2.getOrDefault(l,0);\n            map2.put(l,count+1);\n        }\n        for(int i=0;i<nums1.length;i++){\n            for(int j=i+1;j<nums1.length;j++){\n                long p=(long)nums1[i]*(long)nums1[j];\n                if(map2.getOrDefault(p,0)>0){\n                    re+=map2.get(p);\n                }\n            }\n        }\n        return re;\n    }\n}\n```
[]