O(N2) complexity
Intuition\n Describe your first thoughts on how to solve this problem. \nIf the target value is a multiple of the element in the list, then the % will be 0. To 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf the target value is a multiple of the element in the list, then the % will be 0. To avaoid mulitple calculation a dict can be used to store the values.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTo calculate the pairs, lets have a list and a target. we iterate over the list and check if the element is a factor of the target and if so, before incrementing the count, lets check a dict if there\'s a complementing factor for this element so that factor 1 * factor 2 = target. If there is, add the count of that factor to the total value. While we iterate over the list, we keep count of the factors so that they might become the factor 1\'s for some other elements we are yet to iterate over. \n# Complexity\n- Time complexity: O(N2)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def numTriplets(self, nums1: List[int], nums2: List[int]) -> int:\n        from collections import defaultdict\n        nums1.sort()\n        nums2.sort()\n        def findtarget(l,t):\n            c=0\n            d=defaultdict(int)\n            #l.sort()\n            #print("l,  target", l,t)\n            for i in l:\n                if t%i==0:\n                    c+=d[int(t/i)]\n                d[i]+=1\n            #print("c: ",c)\n            return c\n        def common(l,l1):\n            #print("l,l1", l,l1)\n            c=0\n            d=defaultdict(int)\n            for i in l:\n              #  print("i,l", i,l, d)\n                if d[i*i]>0:\n                    c+=d[i*i]\n                else:\n                    x=findtarget(l1,i*i)\n                    d[i*i]+=x\n                    c+=x\n           # print("### returning c",c)\n            return c\n        total=common(nums1,nums2)+common(nums2,nums1)\n        return total\n```
['Python3']