I guess my logic is right but still cant find mistake.
Only one test case is running
Hey @abhinavsehgal802_270a44594b6dc4ad,
You had an incorrect condition ie. when the sum+arr[count] is less than the target:
In that case we will try to increase our sum so, instead of breaking we will update our low to low+1.
while(low<right)
{
int sum=arr[low]+arr[right];
if(sum+arr[count]>t)
{
right--;
}
else if(sum+arr[count]==t)
{
System.out.print(arr[count]+ ", " + arr[low]+" and " +arr[right]);
System.out.println();
low++;
right--;
}
else
{
low++; // change this increase the sum instead of breaking
}
Hope it helps
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.