Ultra fast mathematician problem---

what is error in my logic-------
import java.util.;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t>0){
int n1 = cin.nextInt(), n2 = cin.nextInt(), n = 0;
while(n1>0&&n2>0){
int d1 = n1% 10, d2 = n2 % 10;
if(d1 == d2){
n = n
10+0;
}else{
n = n*10+1;
}
n1 = n1 / 10;
n2 = n2 / 10;
}
System.out.println(n);
t–;
}
}
}

Hi Abhishek,
First of all, you should use strings to attempt this question because its given that length of string is <=100. Second, in the code snippet:
int d1 = n1 % 10, d2 = n2 % 10;
if (d1 == d2) {
n = n * 10 + 0;
} else {
n = n * 10 + 1;
}
Here you are multiplying n by 10 and comparing n1%10 and n2%10. This will basically compare the last 2 digits of input numbers and in the answer should be at last as well. But because of n=n*10 it will move to the beginning. Try solving it by taking input of strings and use stringbuilder to compute your answer since strings in Java are immutable.