cpp

Sum equal to sum

carnato

Vishal Yadav

Posted on January 22, 2022

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
πŸ’– πŸ’ͺ πŸ™… 🚩
carnato
Vishal Yadav

Posted on January 22, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related