Brute Force Slowish
Code\n\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        def count_triplets(nums1: List[int], nums2: List[int]) -
# Code\n```\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        def count_triplets(nums1: List[int], nums2: List[int]) -> int:\n            count = 0\n            product_map = defaultdict(int)\n\n            for i in range(len(nums1)):\n                for j in range(i + 1, len(nums1)):\n                    product_map[nums1[i] * nums1[j]] += 1\n\n            for i in range(len(nums2)):\n                square = nums2[i] * nums2[i]\n                count += product_map[square]\n\n            return count\n\n        return count_triplets(nums1, nums2) + count_triplets(nums2, nums1)\n\n```
['Python3']