When compiling it’s workin but failed all the test cases not getting the error with the code .
here is my code
#include
#include
using namespace std;
int main(){
int n,target;
cin>>n;
int a[1000];
for(int i=0;i<n;i++){
cin>>a[i];
}
cin>>target;
sort(a,a+n);
int left=0;
int right=n-1;
for(int i=0;i<n;i++){
while(left<right){
if(a[left] + a[right] + a[i]==target){
cout<<a[i]<<", "<<a[left]<<" and "<<a[right]<<endl;
left++;
right--;
}
else if(a[left] + a[right] +a[i]> target){
right--;
}
else if(a[left] + a[right] + a[i] < target){
left++;
}
}
}
return 0;
}