Triple sum in array

PHOTO EMBED

Sun Jun 26 2022 18:29:58 GMT+0000 (UTC)

Saved by @Ranjan_kumar #c++

class Solution{
    public:
    //Function to find if there exists a triplet in the 
    //array A[] which sums up to X.
    bool find3Numbers(int A[], int n, int X)
    {
        //Your Code Here
         int j;
    int k;
    //Your Code Here
    sort(A,A+n);
    for(int i=0;i<n-2;i++)
    {
       j=i+1;
       k=n-1;
       while(j<k)
       {
         if(A[i]+A[j]+A[k]==X) return 1;
         if(A[i]+A[j]+A[k]>X) k--;
         else j++;
       }
    }
    return 0;
    }

};
content_copyCOPY

https://practice.geeksforgeeks.org/problems/triplet-sum-in-array-1587115621/1