Python, Hashmap
\nclass Solution(object):\n    def numTriplets(self, nums1, nums2):\n\n        cnt = 0\n        a = collections.defaultdict(int)\n        b = collections.defaul
```\nclass Solution(object):\n    def numTriplets(self, nums1, nums2):\n\n        cnt = 0\n        a = collections.defaultdict(int)\n        b = collections.defaultdict(int)\n        \n        for num in nums1:\n            a[num*num] += 1\n        \n        for num in nums2:\n            b[num*num] += 1\n            \n        for j in range(len(nums2)):\n            for k in range(j+ 1, len(nums2)):\n                c = nums2[j]*nums2[k]\n                if c in a: cnt += a[c] \n                        \n        for j in range(len(nums1)):\n            for k in range(j+1, len(nums1)):\n                c = nums1[j]*nums1[k]\n                if c in b: cnt += b[c] \n        \n        return cnt\n```
['Python']