Skip to content

Commit 708dc43

Browse files
add 2660
1 parent ea493d5 commit 708dc43

File tree

2 files changed

+30
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+30
-0
lines changed

Diff for: paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
| 2673 | [Make Costs of Paths Equal in a Binary Tree](https://leetcode.com/problems/make-costs-of-paths-equal-in-a-binary-tree/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2673.java) | | Medium |Tree, DFS, Greedy
2121
| 2678 | [Number of Senior Citizens](https://leetcode.com/problems/number-of-senior-citizens/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2678.java) | | Easy |
2222
| 2670 | [Find the Distinct Difference Array](https://leetcode.com/problems/find-the-distinct-difference-array/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2670.java) | | Easy |
23+
| 2660 | [Determine the Winner of a Bowling Game](https://leetcode.com/problems/determine-the-winner-of-a-bowling-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2660.java) | | Easy |
2324
| 2643 | [Row With Maximum Ones](https://leetcode.com/problems/row-with-maximum-ones/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2643.java) | | Easy |
2425
| 2641 | [Cousins in Binary Tree II](https://leetcode.com/problems/cousins-in-binary-tree-ii/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2641.java) | | Medium |Tree, BFS, HashTable
2526
| 2605 | [Form Smallest Number From Two Digit Arrays](https://leetcode.com/problems/form-smallest-number-from-two-digit-arrays/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2605.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2660 {
4+
public static class Solution1 {
5+
public int isWinner(int[] player1, int[] player2) {
6+
int sum1 = computeSum(player1);
7+
int sum2 = computeSum(player2);
8+
if (sum1 < sum2) {
9+
return 2;
10+
} else if (sum1 > sum2) {
11+
return 1;
12+
} else {
13+
return 0;
14+
}
15+
}
16+
17+
private int computeSum(int[] pins) {
18+
int sum = 0;
19+
for (int i = 0; i < pins.length; i++) {
20+
if (i > 0 && pins[i - 1] == 10 || (i > 1 && pins[i - 2] == 10)) {
21+
sum += pins[i] * 2;
22+
} else {
23+
sum += pins[i];
24+
}
25+
}
26+
return sum;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)