Similar Pairs Codeforces Solution

Similar Pairs Codeforces Solution

In this post, the Similar Pairs Codeforces Solution is given. Question details : Codeforces Round #644 (Div. 3), problem: (C) Similar Pairs.

Similar Pairs Codeforces Solution

#include<bits/stdc++.h>
using namespace std;
const int MOD=1000000007;
#define ll long long
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
Fastio;
ll t; cin>>t;
while(t--)
{
ll n,x,ce=0,co=0,flag=0; vector<ll> v;
cin>>n;
for(ll i=0;i<n;i++)
{
cin>>x;
v.push_back(x);
if(x%2==0)
ce++;
else
co++;
}
if(ce%2==0 && co%2==0)
{
cout<<"YES"<<endl;
flag=1;
}
else
{
sort(v.begin(),v.end());
for(ll i=0;i<v.size();i++)
if(v[i+1]-v[i]==1)
{
cout<<"YES"<<endl;
flag=1;
break;
}
}
if(flag==0)
cout<<"NO"<<endl;
}
}


The solution of the above program is contributed by Vishal Vaibhab (IIT BHU). If you like TheCode11, then do follow us on Facebook, Twitter and Instagram.

Post a Comment

Previous Post Next Post

Contact Form