Easy understand python solution
Code\n\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        Count1 = Counter(nums1)\n        Count2 = Counter(nums2)
# Code\n```\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        Count1 = Counter(nums1)\n        Count2 = Counter(nums2)\n        res = 0\n        for i in Count1:\n            db = Count2.copy()\n            while db:\n                item = db.popitem()\n                Q, r = divmod(i*i, item[0])\n                if r == 0 and Q in db:\n                    res += db[Q]*item[1]*Count1[i]\n                    db.pop(Q)\n                elif r == 0 and Q == item[0]:\n                    res += comb(item[1],2)*Count1[i]\n                    \n        for i in Count2:\n            db = Count1.copy()\n            while db:\n                item = db.popitem()\n                Q, r = divmod(i*i, item[0])\n                if r == 0 and Q in db:\n                    res += db[Q]*item[1]*Count2[i]\n                    db.pop(Q)\n                elif r == 0 and Q == item[0]:\n                    res += comb(item[1],2)*Count2[i]\n\n        return res\n                    \n\n```
['Python3']