public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner in=new Scanner(System.in);
int t = in.nextInt();
in.nextLine();
for(int i=0;i<t;i++) {
String s1=in.nextLine();
String s2=in.nextLine();
int a=Integer.parseInt(s1,2);
int b=Integer.parseInt(s2,2);
int count=0;
while (b>0) {
int u=a;
a=a^b;
b=2*(u&b);
count++;
}
System.out.println(count);
}
}
This is how I did it. Although I only got 20 points.
Also, please refrain from using a = ‘0’+a multiple times, as the + operator takes linear time, you would end up getting a ‘TLE’. I would recommend using resize or something similar.