I am solving this problem Playing with Strings and i am stuck. I don’t know where the code is going wrong , i tried several test case and tried custom input through which getting right output.
here the code is
/* package codechef; // don’t place package name! */
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
{
// your code goes here
try {
Scanner sc = new Scanner(System.in);
// InputStreamReader r=new InputStreamReader(System.in);
// BufferedReader br = new BufferedReader(r);
int t = sc.nextInt();//Integer.parseInt(br.readLine());
for(int i=0;i<t;i++)
{
int n =sc.nextInt(); //Integer.parseInt(br.readLine());
int S = sc.nextInt();//Integer.parseInt(br.readLine());
int R = sc.nextInt();//Integer.parseInt(br.readLine());
int first0=0,first1=0,sec0=0,sec1=0;
for(int j=0;j<n;j++)
{
if(S%10==0)
{
first0++;
//System.out.println("first0= "+first0);
}
else
{
first1++;
//System.out.println("first1= "+first1);
}
S=S/10;
if(R%10==0)
{
sec0++;
//System.out.println("sec0= "+sec0);
}
else
{
sec1++;
//System.out.println("sec1= "+sec1);
}
R=R/10;
}
if(first0==sec0 && first1==sec1)
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
}
}
catch(Exception e)
{
return;
}
}
}