# Help me in solving PLAYSTR problem. I have written the code properly but still I am unable to submit

### My code

``````#include <iostream>
#include <math.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
string str1, str2;
cin>>str1;
cin>>str2;
int count1=0;
int count2=0;

for(int i=0;i<n;i++)
{
if(str1[i] == '0')
{
count1++;
}
}

for(int i=0;i<n;i++)
{
if(str2[i] == '0')
{
count2++;
}
}
if(count1 == count2)
{
cout<<"yes\n";
}
else
{
cout<<"no\n";
}
}
return 0;
}

``````

Problem Link: PLAYSTR Problem - CodeChef

@ ayushagrawal07 You also need to count the ‘1’.
this code reads an integer n and two strings s and r . It counts the occurrences of ‘0’ and ‘1’ character in each string separately and compares the count . Based on the comparisons , it prints either “Yes” if the counts are equal or “No” if the counts are not equal…
here is my code for this problem.

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t–> 0){
int n = sc.nextInt();
String a = sc.next();
String b = sc.next();
int a_0=0 , a_1=0 , b_0=0 , b_1=0;
int i=0 ;
for(i=0 ; i<n ; i++){
if(a.charAt(i) != ‘0’){
a_0++;
}
else{
a_1++;
}
if(b.charAt(i) != ‘0’){
b_0++;
}
else{
b_1++;
}
}
if(a_0==b_0 && a_1==b_1){
System.out.println(“YES”);
}
else{
System.out.println(“NO”);
}
}
}
}