This is Discussion thread about Ultra Fast Mathematicians
Discussion About Ultra Fast Mathematicians
import java.util.Scanner;
class Code {
public static void main(String a[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
for (int i = 0; i < n; i++) {
String first = sc.next();
String second = sc.next();
String ans="";
for(int j=0 ; j<first.length();j++){
ans = ans + (first.charAt(j) ^ second.charAt(j));
}
System.out.print(ans);
}
}
}
what’s the error in this one test case got failed
import java.util.Scanner;
public class Main {
int arr1[]=new int[100];
int arr2[]=new int[100];
int arr3[]=new int[100];
String s1;
String s2;
void input()
{
Scanner sc=new Scanner(System.in);
System.out.print("");
s1=sc.next();
System.out.print("");
s2=sc.next();
}
void convert()
{
char ch;
int x=0;
for(int i=0;i<s1.length();i++)
{
ch=s1.charAt(i);
x=(int)ch;
arr1[i]=x;
}
for(int i=0;i<s2.length();i++)
{
ch=s2.charAt(i);
x=(int)ch;
arr2[i]=x;
}
}
void compute()
{
for(int i=0;i<s1.length();i++)
{
if(arr1[i]!=arr2[i])
{
arr3[i]=1;
}
else
{
arr3[i]=0;
}
}
}
void display()
{
for(int i=0;i<s1.length();i++)
{
System.out.print(arr3[i]);
}
}
public static void main(String[]args)
{
Main obj=new Main();
Scanner s=new Scanner(System.in);
System.out.println();
int t=s.nextInt();
while(t>0)
{
obj.input();
obj.convert();
obj.compute();
obj.display();
t--;
}
}
}
What’s the error in this?
I’m getting wrong answer