Problem in code submission

heyy i m getting one test case as wrong answer. can you tell me which of the test inputs its not passing?

#include
#include <bits/stdc++.h>
using namespace std;
int main() {
int n,m,left,right,i;
cin>>n;
int arr[n];
for(i=0;i<n;i++)
{
cin>>arr[i];
}
cin>>m;
sort(arr,arr+n);

i=0;
while(i<n-2)
{
    left=i+1, right=n-1;
    while(left<right)
    {
        if(arr[left]+arr[right]==m-arr[i])
        {
            cout<<arr[i]<<", "<<arr[left]<<" and "<<arr[right]<<endl;
            left++;
            right--;
        }
        else if(arr[left]+arr[right]>m-arr[i])
        {
            right--;
        }
        else
        {
            left++;
        }
    }

    i++;
}
return 0;

}

@Aparna Consider a test case:
4
2 2 2 2
6

Expected Output:
2, 2 and 2
2, 2 and 2
2, 2 and 2

Your Output:
2, 2 and 2
2, 2 and 2

To correct this:(Just remove right-- from this condition and then check.)
if(arr[left]+arr[right]==m-arr[i])
{
cout<<arr[i]<<", “<<arr[left]<<” and "<<arr[right]<<endl;
left++;
// right–;
}

Hope this helps :slightly_smiling_face: