compareTriplets * three categories: clarity, originality and difficulty * par

25 阅读1分钟
/**
 * compareTriplets
 * three categories: clarity, originality and difficulty
 * parameter is two array
 *  alice arr and bob arr
 *  compare tow array
 *  if arrAlice's rates element is greate than arrBob's rates element one by one
 *   Alice get one score
 *   else if arrAlice's rete element is less than arrBob's retes element one by one
 *   Bob get one score
 *   else equals null get any score
 *   return array[aliceScore,bobScore]
 *   constraints
 *   1<=a[i]<=100
 *   1<=b[i]<=100
 * @param a
 * @param b
 * @return
 */
public static List<Integer> compareTriplets(List<Integer> a,List<Integer> b){
    if(a==null){
        return null;
    }
    if (a.isEmpty()){
        return null;
    }
    if (b==null){
        return null;
    }
    if (b.isEmpty()){
        return null;
    }
    for (Integer integer : a) {
        if (integer<1 || integer>100){
            return null;
        }
    }
    for (Integer integer : b) {
        if (integer<1 || integer>100){
            return null;
        }
    }
    int aliceScoreEleIndex0=a.get(0);
    int aliceScoreEleIndex1=a.get(1);
    int aliceScoreEleIndex2=a.get(2);
    int bobScoreEleIndex0=b.get(0);
    int bobScoreEleIndex1=b.get(1);
    int bobScoreEleIndex2=b.get(2);
    int aliceScore=0;
    HashSet<String> aliceScoreHashSet = new HashSet<>();
    int bobScore=0;
    HashSet<String> bobScoreHashSet = new HashSet<>();
    int count=0;
    while(true){
        if (aliceScoreEleIndex0>bobScoreEleIndex0){
            aliceScore+=1;
            String aliceScoreStr=aliceScore+"aliceScore_EleIndex0_great_than";
            aliceScoreHashSet.add(aliceScoreStr);
        } else if (aliceScoreEleIndex0<bobScoreEleIndex0) {
            bobScore+=1;
            String bobScoreStr=bobScore+"bobScore_EleIndex0_great_than";
            bobScoreHashSet.add(bobScoreStr);
        }
        if (aliceScoreEleIndex1>bobScoreEleIndex1){
            aliceScore+=1;
            String aliceScoreStr=aliceScore+"aliceScore_EleIndex1_great_than";
            aliceScoreHashSet.add(aliceScoreStr);
        } else if (aliceScoreEleIndex1<bobScoreEleIndex1) {
            bobScore+=1;
            String bobScoreStr=bobScore+"bobScore_EleIndex1_great_than";
            bobScoreHashSet.add(bobScoreStr);
        }
        if (aliceScoreEleIndex2>bobScoreEleIndex2){
            aliceScore+=1;
            String aliceScoreStr=aliceScore+"aliceScore_EleIndex2_great_than";
            aliceScoreHashSet.add(aliceScoreStr);
        } else if (aliceScoreEleIndex2<bobScoreEleIndex2) {
            bobScore+=1;
            String bobScoreStr=bobScore+"bobScore_EleIndex2_great_than";
            bobScoreHashSet.add(bobScoreStr);
        }
        count++;
        if (count>1000000){
            break;
        }
    }
    Set<String> aliceScoreSumSet=new HashSet<String>();
    for (String string : aliceScoreHashSet) {
        if (string.contains("aliceScore_EleIndex0_great_than")){
            aliceScoreSumSet.add("aliceScore_EleIndex0_great_than");
        } else if (string.contains("aliceScore_EleIndex1_great_than")) {
            aliceScoreSumSet.add("aliceScore_EleIndex1_great_than");
        }else if (string.contains("aliceScore_EleIndex2_great_than")){
            aliceScoreSumSet.add("aliceScore_EleIndex2_great_than");
        }
    }
    List<Integer> intList = new ArrayList<>();
    intList.add(aliceScoreSumSet.size());
    Set<String> bobScoreSumSet = new HashSet<String>();
    for (String string : bobScoreHashSet) {
        if (string.contains("bobScore_EleIndex0_great_than")){
            bobScoreSumSet.add("bobScore_EleIndex0_great_than");
        }else if (string.contains("bobScore_EleIndex1_great_than")){
            bobScoreSumSet.add("bobScore_EleIndex1_great_than");
        } else if (string.contains("bobScore_EleIndex2_great_than")) {
            bobScoreSumSet.add("bobScore_EleIndex2_great_than");
        }
    }
    intList.add(bobScoreSumSet.size());
    return intList;
}
```
```