Sorting (array sum triplet)

Problem-> https://hack.codingblocks.com/app/contests/1975/195/problem

Code->

I am not able to understand code from line 25-30.please explain this.??

Hello @kaustub this code is even more complicated.
we can discuss here then i can help you in implementing this question in the more simpler way.
do you know about two pointer approach?
in three pointer appraoch we can do like we will start from the for loop:
then the 1st element of the array is first element we have choose and now with that element we will apply two pointer appraoch.
like :
suppose j is our 1+1th element and k is our n-1 th element then we will try to do until j is less then k in indexing.
if at any point the sum of these three becomes more then the target then we will decrease k from index and if at any point the sum of these 3 is less than k then we will increse the value of j pointer.
and if the sum is equal to target then we will print that combination and then we can increse j andd decrese k.
Here for your reference i amm attaching the code for you :
if you have any doubt you can ask here:


Happy Learning!!

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.