#include
#include
using namespace std;
void sum(int a[],int n,int target)
{
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(target==(a[i]+a[j]))
{
cout<<a[i]<<" and "<<a[j]<<endl;
}
}
}
}
int main() {
int a[2000];
int n;
int target;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
cin>>target;
sort(a,a+n);
sum(a,n,target);
return 0;
}
my code is this and it passing all test cases but complexity is order of n square is there any efficient way to do it