Triplets of an integer array.

Please guyes help me to finding the all possilbe triplets of an array with below constraints

suppose given array is arr[] with n elements with some repeating elements but each element may occur atmost 2 times.
and also
arr[i] < arr[j] < arr[k] for any i < j < k.

i have solved this problem in O(n*n) time complexity but not getting more optimized solution so please help me.

Test Case

6
1 2 3 1 2 4
o/p = 4;
1 Like

Hey this is an interviewstreet challenge problem . Best of luck .

Yes you are right.

//