DEV Community

Vishal Yadav
Vishal Yadav

Posted on

Sum equal to sum

Solution

#include<bits/stdc++.h>
using namespace std;

int main()
{
   int a[]={4,11,5,13};
   int n=4;
   unordered_set<int>mp;
   for(int i=0;i<n;i++)
   {
       for(int j=i+1;j<n;j++)
       {
           int sum=a[i]+a[j];
           if(mp.find(sum)!=mp.end())
           cout<<1;
           mp.insert(sum);
       }
   }
   cout<<0;

    return 0;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)