Code doesnt work fine for triplet sum array

hello @varun1928.joshi
sort ur array and then run three loop.


first loop from i=0 to n-1
second loop j=i+1 to n-1
third loop k=j+1 to n-1
and then if a[i]+a[j]+a[k]==target then print that triplet

i cannot figure this out sir

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

…

have u studied array target pair sum problem?

here the approach is exactly like that.
we first sort the array.
and then we fix one element and for remaining two we use two pointer approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.