The Java solution posted for this problem is not passing the test cases itself. I


#1

The Java solution posted for this problem is not passing the test cases itself. I know its a user generated solution but still, I was under the impression that these user generated solutions are randomly picked up from a pool of user submitted codes that have passed all test cases successfully.


#2

Hey Prateek,
You are right. We choose from the solutions which are accepted. However, the test data has evolved over time, and solutions which passed at one point of time may not pass now. We are working on making the selection of solutions better.


#3

passes all testcases dont think can be done without biginteger

   > public class Solution {
>         public int compareVersion(String A, String B) {
>             if(A.equals(B))
>                 return 0;
>             int i = 0;
>             int j = 0;
>             java.math.BigInteger aa = new java.math.BigInteger("0");
>             java.math.BigInteger bb = new java.math.BigInteger("0");
>             java.math.BigInteger ten = new java.math.BigInteger("10");
>             while(i<A.length()||j<B.length())
>             {
>                 while(i<A.length()&&A.charAt(i)!='.')
>                 {
>                     aa = (aa.multiply(ten)).add(new java.math.BigInteger(A.charAt(i)+""));
>                     i++;
>                 }
>                 while(j<B.length()&&B.charAt(j)!='.')
>                 {
>                     bb = (bb.multiply(ten)).add(new java.math.BigInteger(B.charAt(j)+""));
>                     j++;
>                 }
>                 if(aa.compareTo(bb)>0)
>                     return 1;
>                 if(aa.compareTo(bb)<0)
>                     return -1;
>                 i++;
>                 j++;
>                 aa = new java.math.BigInteger("0");
>                 bb = new java.math.BigInteger("0");
>             }
>             return 0;
>         }
>     }