Doubt related triplet output


what is wrong in this code ? I have submit it and it fails on one test case?

Can you explain me your approach?
how is it related with triplets?

I think you have asked another question doubt with a different question. This is a count set bits question

take as input n ,the size of array.take n more inputs and store that in an array.take as input"target ", a number . write a function which prints all triplets of numbers which sum to target.

this question belongs to array section

please respond to my doubt

Okay so you have asked the question with some different question content. its okay

break your code if you find one solution. Also, i loop will go from 0 to arr.size-2 as i wont start for the last 2 elements. You can refer this:
for (int i = 0; i < arr_size - 2; i++) {

        // To find the other two elements, start two index variables 
        // from two corners of the array and move them toward each 
        // other 
        l = i + 1; // index of the first element in the remaining elements 
        r = arr_size - 1; // index of the last element 
        while (l < r) { 
            if (A[i] + A[l] + A[r] == sum) { 
                System.out.print("Triplet is " + A[i] + ", " + A[l] + ", " + A[r]); 
                return true; 
            } 
            else if (A[i] + A[l] + A[r] < sum) 
                l++; 

            else // A[i] + A[l] + A[r] > sum 
                r--; 
        } 
    } 

    // If we reach here, then no triplet was found 
    return false;

why you are not responding to my doubt?

I just did, read my last message and correct your code. I wont be doing it for you, I’ll just correct you

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.