Array target sum triplets

i am not able to figure out what to do in this

Hello @shubham3399z,

You have to use the logic of array target sum pair to solve array target sum triplets.

Approach:

  1. Sort the array.
  2. take three-pointers i, j and k.
  3. i will iterate for index 0 to n-3.
    3.1. for each value of i, use the logic of array target sum pair for the subarray from i+1 to n-1.
    3.2. Check for a[i]+a[j]+a[k]==target, a[i]+a[j]+a[k]<target and a[i]+a[j]+a[k]>target.

Hope, this would help.
Give a like, if you are satisfied.

1 Like

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.