Невозможно определить CTS тесты для Android NNAPI для входов / выходов SOFTMAX

My java Solution

 public int compareVersion(String version1, String version2) {

    String[] first = version1.split("\\.");
    String[] second = version2.split("\\.");

    int len = first.length<=second.length? first.length:second.length;

    // the loop runs for whichever is the short version of two strings
    for(int i=0;i<len;i++){
      int firstInt = Integer.parseInt(first[i]);
      int secondInt = Integer.parseInt(second[i]);
        if(firstInt<secondInt){
            return -1;
        }
        else if(firstInt>secondInt){
            return 1;
        }
    }

    // below two condition check if the length are the not the same

    //if first string length is short then start from after first string length and compare it with second string value. second string value is not zero that means it is greater.
    if(first.length<second.length){
        for(int i=first.length;i<second.length;i++){
            int secondInt = Integer.parseInt(second[i]);
            if(secondInt!=0){
                return -1;
            }
        }
    }
    // similar logic as above just that first length is grater this time.
     else if(first.length>second.length){
        for(int i=second.length;i<first.length;i++){
            int firstInt = Integer.parseInt(first[i]);
            if(firstInt!=0){
                return 1;
            }
        }        
    }

    // return 0 if both string value is the same
    return 0;

}
0
задан Atul Vaish 18 January 2019 в 03:14
поделиться