Skip to content

Commit f6b4d6b

Browse files
committed
c++ code solution palindrome flipping
1 parent 2ebf869 commit f6b4d6b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

palindromeflipping.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//shree ganeshay namah
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
#define pi (3.141592653589)
6+
#define mod 1000000007
7+
#define ll long long
8+
#define float double
9+
#define pb push_back
10+
#define mp make_pair
11+
#define ff first
12+
#define ss second
13+
#define all(c) c.begin(), c.end()
14+
#define min3(a, b, c) min(c, min(a, b))
15+
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
16+
#define rrep(i, n) for(int i=n-1;i>=0;i--)
17+
#define rep(i,n) for(int i=0;i<n;i++)
18+
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
19+
20+
21+
int main()
22+
{
23+
24+
25+
int t;
26+
cin>>t;
27+
while(t--)
28+
{
29+
int n;
30+
cin>>n;
31+
string as;
32+
cin>>as;
33+
int c1=0,c0=0;
34+
for (int i = 0; i < n; i++)
35+
{
36+
if(as[i] == '1')
37+
c1++;
38+
else
39+
c0++;
40+
}
41+
if(n%2==0){
42+
if(c1%2 && c0%2)
43+
cout<<"NO"<<endl;
44+
else
45+
cout<<"YES"<<endl;
46+
}
47+
else{
48+
cout<<"YES"<<endl;
49+
}
50+
51+
}
52+
return 0;
53+
}

0 commit comments

Comments
 (0)