# Algorithm – Collatz Conjecture encounters two numbers in Java and receives the wrong answer

I literally have several test cases, it's over, I even fixed TLE with Long. Could someone help me figure out what I'm doing wrong?
Below is my code:

``````import java.io.BufferedReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class CollatzConjecture {

public static void printAnswer(long a,long aSteps, long b, long bSteps, long meet) {
System.out.println(a + " needs " + aSteps + " steps, " + b + " needs " + bSteps + " steps, they meet at " + meet);
}

public static void main(String() args) {
long a,b;
Scanner in = new Scanner(System.in);

a = in.nextInt();
b = in.nextInt();
HashMap aList = new HashMap();
HashMap bList = new HashMap();

while(a!=0 && b!= 0) {
long originalA = a;
long originalB = b;
long aSteps = 0, bSteps = 0;
aList.put(originalA, aSteps);
bList.put(originalB, bSteps);
if(a==1 && b==1) {
}
if(a==b) {
}
else {
while(a!=1) {
if (a%2 == 1){
a = 3 * a + 1;
aList.put(a, aSteps);
}
else {
a /= 2;
aList.put(a, aSteps);
}
aSteps+=1;
if(aList.containsKey(b)) {
meet = b;
// printAnswer(originalA, aSteps, originalB, bSteps, b);
break;
}
}
if(b%2 == 1) {
b = 3 * b + 1;
}
else {
b/=2;
}
bSteps+=1;
if(aList.containsKey(b)) {
meet = b;
// printAnswer(originalA, aList.get(b) + 1, originalB, bSteps, b);
break;
}

}