Square of number equals product of two other numbers

I have two lists with 50K Integers each. All elements in lists are unique. There is an uppwer limit of 100000 on each number. I want to find out what elements in one list are such that they equal the product of two in other. I print out as triplets. For example if the lists are {1,4,9) and {3,6) then 6,4,9 is one such triplet, since 6X6=4X9. Another such triplet is (3,1,9) (Thanks to @rajeshk92 for pointing it out). It is easy to find a solution with O(n*n) can it be done better like O(n) or O(nlogn) complexity?

Comments (2)