Respected sir
After compiling this code its showing signal 15, wall time exceeded.
#include
#include
using namespace std;
int main()
{
int N,current_sum=0;
int target;
cin>>N;
int a[N];
for(int i=0;i<N;i++)
{
cin>>a[i];
}
cin>>target;
sort(a,a+N);
int i=0;
int j=N-1;
while(i<j)
{
current_sum=a[i]+a[j];
if(current_sum>target)
{
j--;
}
else if(current_sum==target){
cout<<a[i]<<" and "<<a[j];
}
else i++;
}
return 0;
}
Please help.
Thanks
Manah Verma