根据输入数组的整数值返回数组 {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
相关推荐
96779 分钟前
理解IOC控制反转和spring容器,@Autowired的参数的作用
java·sql·spring
SY_FC9 分钟前
实现一个父组件引入了子组件,跳转到其他页面,其他页面返回回来重新加载子组件函数
java·前端·javascript
啵啵鱼爱吃小猫咪26 分钟前
机械臂阻抗控制github项目-mujoco仿真
开发语言·人工智能·python·机器人
似水明俊德26 分钟前
02-C#
开发语言·c#
耀耀_很无聊27 分钟前
09_Jenkins安装JDK环境
java·运维·jenkins
ノBye~29 分钟前
Centos7.6 Docker安装redis(带密码 + 持久化)
java·redis·docker
黑臂麒麟30 分钟前
openYuanrong:多语言运行时独立部署以库集成简化 Serverless 架构 & 拓扑感知调度:提升函数运行时性能
java·架构·serverless·openyuanrong
放下华子我只抽RuiKe530 分钟前
算法的试金石:模型训练、评估与调优的艺术
人工智能·深度学习·算法·机器学习·自然语言处理·数据挖掘·线性回归
oem11032 分钟前
C++中的享元模式实战
开发语言·c++·算法
流云鹤34 分钟前
每日一题0316
算法