Easy Python Solution with proper and easy explanation
Okay so I followed a really simple stragegy:\nI created 2 dictionaries and put up the squared values of all the numbers in both the nums array in seperate dicti
Okay so I followed a really simple stragegy:\nI created 2 dictionaries and put up the squared values of all the numbers in both the nums array in seperate dictionaries, with their count\nNow I traverse both the arrays seperately and find out pairs such that, if the pair product is in the opposite dictionary, i.e, if I am looking for pairs in nums2 then i chech the values in ds1(dictionary for nums1 squared values) \nsimilarly for nums1 as well, this is really easy\n```\n\t\tds1 = dict()\n        ds2 = dict()\n        \n        for i in nums1:\n            val = i*i\n            ds1[val] = ds1.get(val, 0) + 1\n        \n        for i in nums2:\n            val = i*i\n            ds2[val] = ds2.get(val, 0) + 1\n        \n        ans = 0\n        \n        for i in range(len(nums2)):\n            for j in range(i+1, len(nums2)):\n                v1 = nums2[i]\n                v2 = nums2[j]\n                fv = v1*v2\n                if fv in ds1:\n                    ans += ds1[fv]\n        for i in range(len(nums1)):\n            for j in range(i+1, len(nums1)):\n                v1 = nums1[i]\n                v2 = nums1[j]\n                fv = v1*v2\n                if fv in ds2:\n                    ans += ds2[fv]\n        \n        return ans\n```
[]