@anshumansingh the following editorial’s solution is wrong and every other solution that is using “unsigned long long int” is also wrong…
int Solution::compareVersion(string A, string B) {
int i=0,j=0,m=A.length(),n=B.length();
unsigned long long int val1=0,val2=0;
while(i<m or j<n){
val1=0,val2=0;
while(i<A.length() and A[i]!='.'){
val1=(val1*10)+(A[i++]-'0');
}
while(j<B.length() and B[j]!='.'){
val2=(val2*10)+(B[j++]-'0');
}
if(j<n and B[j]=='.') ++j;
if(i<m and A[i]=='.') ++i;
if(val1>val2) return 1;
else if(val1<val2) return -1;
}
return 0;
}
And test-case on which these are failing is :
18446744073709551614
18446744073709551620