2023每日刷题(七十二)

Leetcode—2660.保龄球游戏的获胜者

实现代码

class Solution {public:int isWinner(vector<int>& player1, vector<int>& player2) {long long sum1 = 0, sum2 = 0;int n = player1.size();for(int i = 0; i < n; i++) {sum1 += player1[i];sum2 += player2[i];if((i - 1 >= 0 && player1[i - 1] == 10) || (i - 2 >= 0 && player1[i - 2] == 10)) {sum1 += player1[i];}if((i - 1 >= 0 && player2[i - 1] == 10) || (i - 2 >= 0 && player2[i - 2] == 10)) {sum2 += player2[i];}}if(sum1 > sum2) {return 1;}if(sum1 == sum2) {return 0;} else {return 2;}}};

运行结果


之后我会持续更新,如果喜欢我的文章,请记得一键三连哦,点赞关注收藏,你的每一个赞每一份关注每一次收藏都将是我前进路上的无限动力 !!!↖(▔▽▔)↗感谢支持!