Let A be an array of n positive integers, and k a given integer.
I’m looking for algorithm to find if there is a pair of elements in the array such that
A[i] * A[j] == k and A[i] == A[j] + k. If there is such a pair, the algorithm should return their index.
This is a homework exercise, and we’re told that there is an O(n*log(n)) solution.
Here is somewhat clarified Graphics Noob’s solution.
Also, it is more like O(N) (assuming hashing won’t fail us), not O(N*log(N)).