Hello all,
Could someone share their thoughts on the problem mentioned below:
Given an array of sorted integers, find the number of unique triplets such that (a[i]*a[k])+a[j]=target and i<j<k.
Ex: A={1,3,3,5,5} and target=18 o/p should be {[3,3,5]} . Explanation a[1]*a[3]+a[2].
I know we can solve it in O(n^2) time.
Ques-1: Can we solve it in less than O(n^2) time. If yes, how? Quest-2: What if the given array is not sorted? What will be the time complexity in this case?
Thanks in advance.