Python intuitive hashmap solution, O(n*m) time
\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        sqr1, sqr2 = defaultdict(int), defaultdict(int)\n        m, n 
```\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        sqr1, sqr2 = defaultdict(int), defaultdict(int)\n        m, n = len(nums1), len(nums2)\n        for i in range(m):\n            sqr1[nums1[i]**2] += 1\n        for j in range(n):\n            sqr2[nums2[j]**2] += 1\n            \n        res = 0 \n        for i in range(m-1):\n            for j in range(i+1, m):\n                if nums1[i]*nums1[j] in sqr2:\n                    res += sqr2[nums1[i]*nums1[j]]\n                    \n        for i in range(n-1):\n            for j in range(i+1, n):\n                if nums2[i]*nums2[j] in sqr1:\n                    res += sqr1[nums2[i]*nums2[j]]\n        return res\n```
['Python', 'Python3']