File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ //code for xorpalindrome in Java
2
+
3
+ import java .util .*;
4
+ import java .lang .*;
5
+ import java .io .*;
6
+
7
+
8
+ class Xorpalindrome
9
+ {
10
+ public static void main (String [] args ) throws java .lang .Exception
11
+ {
12
+ // your code goes here
13
+ BufferedReader br =new BufferedReader (new InputStreamReader (System .in ));
14
+ BufferedWriter bw =new BufferedWriter (new OutputStreamWriter (System .out ));
15
+ int t =Integer .parseInt (br .readLine ());
16
+ StringBuffer sb =new StringBuffer ();
17
+ while (t -->0 )
18
+ {
19
+ int n =Integer .parseInt (br .readLine ());
20
+ String s =br .readLine ();
21
+ int count1 =0 ,count2 =0 ;
22
+ for (int i =0 ;i <s .length ();i ++)
23
+ {
24
+ if (s .charAt (i )=='1' )
25
+ count1 ++;
26
+ else
27
+ count2 ++;
28
+ }
29
+ boolean flag =false ;
30
+ if (n %2 ==0 )
31
+ {
32
+ if (count1 ==count2 ||count1 %2 ==0 &&count2 %2 ==0 )
33
+ flag =true ;
34
+ }
35
+ else
36
+ {
37
+ flag =true ;
38
+ }
39
+ if (flag )
40
+ System .out .println ("YES" );
41
+ else
42
+ System .out .println ("NO" );
43
+ }
44
+ }
45
+ }
You can’t perform that action at this time.
0 commit comments