Python, Hashing, Brute Force
Intuition & ApproachPrecalculate the square of numbers in both lists, and store the frequency. Then iterate through both lists to see if the product of nums2[j]
# Intuition & Approach
Precalculate the square of numbers in both lists, and store the frequency. Then iterate through both lists to see if the product of `nums2[j]*nums2[k]` is in the frequency table of `nums1`. Do the same to the other list.


# Complexity
- Time complexity: $O(N^2)$

- Space complexity: $O(N)$

# Code
```python3 []
class Solution:
    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:
        hash1 = defaultdict(lambda: 0)
        hash2 = defaultdict(lambda: 0)

        for num in nums1:
            hash1[num**2] += 1
        for num in nums2:
            hash2[num**2] += 1
        
        res = 0
        for j in range(len(nums1)):
            for k in range(j+1, len(nums1)):
                res += hash2[nums1[j] * nums1[k]]
        
        for j in range(len(nums2)):
            for k in range(j+1, len(nums2)):
                res += hash1[nums2[j] * nums2[k]]
        
        return res

```
['Python3']