# Good question to start using BigIntegers, had to import it, but remember its an option

#1

import java.math.BigInteger;

public class Solution {
public int compareVersion(String A, String B) {

``````    String[] v1 = A.split("\\.");
String[] v2 = B.split("\\.");

int minLength = Math.min(v1.length, v2.length);

for (int i = 0; i < minLength; i++) {
BigInteger a = new BigInteger(v1[i]);
BigInteger b = new BigInteger(v2[i]);

// System.out.println(v1[i] + " " + v2[i]);
int comp = a.compareTo(b);
if (comp == 1) {
return comp;
} else if (comp == -1) {
return comp;
}
}

if (v1.length == v2.length) {
return 0;
}

boolean longerHasTrailingZeroes = false;
if (v1.length > v2.length) {
longerHasTrailingZeroes = checkTrailingZeroes(v2,v1);
} else {
longerHasTrailingZeroes = checkTrailingZeroes(v1,v2);
}
if (longerHasTrailingZeroes){
return 0;
}

return v1.length > v2.length ? 1 : -1;
}

private boolean checkTrailingZeroes(String[] sh, String[] lo) {
BigInteger z = new BigInteger("0");
for (int i = sh.length; i < lo.length; i++) {
BigInteger l = new BigInteger(lo[i]);
if (l.compareTo(z) != 0) {
return false;
}
}
return true;
}
``````

}