根据输入数组的整数值返回数组 {inputScoreRet[0],inputSocreRet[1]}

java 复制代码
import java.util.ArrayList;

/**
 * Created by Lenovo on 2023/10/4.
 */
public class HackerRankTestCompa {
    public static void main(String[] args) {
        int[] intputRatingNumArr1={1,3,2};
        int[] inputRatingNumArr2={3,0,21};
        int[] scoreArr = getSocreArr(intputRatingNumArr1, inputRatingNumArr2);
        ArrayList<Integer> integers = new ArrayList<>();
        for (int i : scoreArr) {
            integers.add(i);
        }
        System.out.println(integers);
    }

    /**
     * 根据输入数组的整数值 intputArr1{1,1,3} inputArr2{13,3,4}
     * 如果inputArr1[0]==inputArr2[0] inputArrRet1Score get 1 socre inputSCoreRet[0]+=1;
     * 如果 inputArr1[1]>inputArr2[1] inputArrRet1Score get 1 score inplutScoreRet[0]+=1;
     * 否则 inputScoreRet[0]+=0; inputScoreRet[1]+=1;
     * 返回数组 {inputScoreRet[0],inputSocreRet[1]}
     * constraints:
     * 1<=a[i]<=100
     * 1<=b[i]<=100
     * @param intputRatingNumArr1,inputRatingNumArr2
     * @return
     */
    public static int[] getSocreArr(int[] intputRatingNumArr1,int [] inputRaingNumArr2){
        if (intputRatingNumArr1==null){
            return null;
        }
        if (inputRaingNumArr2==null){
            return null;
        }
        if (intputRatingNumArr1.length<1 || intputRatingNumArr1.length>100){
            return null;
        }
        if (inputRaingNumArr2.length<1 || inputRaingNumArr2.length>100){
            return null;
        }

        int inputScoreRetAlice=0;
        int inputScoreRetBob=0;
        for (int i = 0; i < intputRatingNumArr1.length; i++) {
            int i1 = intputRatingNumArr1[i];
            int i2 = inputRaingNumArr2[i];
            if (i1==i2){
                continue;
            }else if (i1>i2){
                inputScoreRetAlice+=1;
            }else {
                inputScoreRetBob+=1;
            }
        }

        return new int[]{inputScoreRetAlice,inputScoreRetBob};
    }
}
复制代码
根据输入数组的整数值 intputArr1{1,1,3} inputArr2{13,3,4}
* 如果inputArr1[0]==inputArr2[0] inputArrRet1Score get 1 socre inputSCoreRet[0]+=1;
* 如果 inputArr1[1]>inputArr2[1] inputArrRet1Score get 1 score inplutScoreRet[0]+=1;
* 否则 inputScoreRet[0]+=0; inputScoreRet[1]+=1;
* 返回数组 {inputScoreRet[0],inputSocreRet[1]}
* constraints:
* 1<=a[i]<=100
* 1<=b[i]<=100
相关推荐
ᅠᅠᅠ@3 分钟前
异常枚举;
开发语言·javascript·ecmascript
凌肖战9 分钟前
力扣上刷题之C语言实现(数组)
c语言·算法·leetcode
编程版小新9 分钟前
C++初阶:STL详解(四)——vector迭代器失效问题
开发语言·c++·迭代器·vector·迭代器失效
陈大爷(有低保)23 分钟前
UDP Socket聊天室(Java)
java·网络协议·udp
c4fx29 分钟前
Delphi5利用DLL实现窗体的重用
开发语言·delphi·dll
秋夫人36 分钟前
B+树(B+TREE)索引
数据结构·算法
kinlon.liu37 分钟前
零信任安全架构--持续验证
java·安全·安全架构·mfa·持续验证
鸽芷咕1 小时前
【Python报错已解决】ModuleNotFoundError: No module named ‘paddle‘
开发语言·python·机器学习·bug·paddle
王哲晓1 小时前
Linux通过yum安装Docker
java·linux·docker
Jhxbdks1 小时前
C语言中的一些小知识(二)
c语言·开发语言·笔记