Question : Given an array of length N. find the number of distinct triplets (A[i],A[j],A[k]) in the array where 0<=i<j<k<N
Example : A = { 1,1,1,1,2}
Output : 2
(1,1,1) and (1,1,2).
What is the optimized approach?
Comments (6)
Question : Given an array of length N. find the number of distinct triplets (A[i],A[j],A[k]) in the array where 0<=i<j<k<N
Example : A = { 1,1,1,1,2}
Output : 2
(1,1,1) and (1,1,2).
What is the optimized approach?