Let's say I have three arrays of positive integers
Z. You can assume that each of the arrays have atmost $N$ elements. All the arrays contain unique elements.
You're allowed to form a triplet of integers $(x,y,z)$ such that $x$, $y$ and $z$ are elements from arrays
I want to count the number of such triplets satisfying the equation $x^2 = yz$. I can only think of an $O(N^2)$ solution using simple hashing. I was wondering if there exists a better solution with a time complexity of $O(N \lg N)$ at least, if not $O(N)$.