Skip to content

Commit c256d2d

Browse files
add 2960
1 parent 6580909 commit c256d2d

File tree

2 files changed

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

2 files changed

+19
-0
lines changed

paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| 2974 | [Minimum Number Game](https://leetcode.com/problems/minimum-number-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2974.java) | | Easy |
55
| 2970 | [Count the Number of Incremovable Subarrays I](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2970.java) | | Easy |
66
| 2965 | [Find Missing and Repeated Values](https://leetcode.com/problems/find-missing-and-repeated-values/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2965.java) | | Easy |
7+
| 2960 | [Count Tested Devices After Test Operations](https://leetcode.com/problems/count-tested-devices-after-test-operations/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2960.java) | | Easy |
78
| 2942 | [Find Words Containing Character](https://leetcode.com/problems/find-words-containing-character/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2942.java) | | Easy |
89
| 2937 | [Make Three Strings Equal](https://leetcode.com/problems/make-three-strings-equal/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2937.java) | | Easy |
910
| 2932 | [Maximum Strong Pair XOR I](https://leetcode.com/problems/maximum-strong-pair-xor-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2932.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2960 {
4+
public static class Solution1 {
5+
public int countTestedDevices(int[] batteryPercentages) {
6+
int ans = 0;
7+
for (int i = 0; i < batteryPercentages.length; i++) {
8+
if (batteryPercentages[i] > 0) {
9+
ans++;
10+
for (int j = i + 1; j < batteryPercentages.length; j++) {
11+
batteryPercentages[j] = Math.max(0, batteryPercentages[j] - 1);
12+
}
13+
}
14+
}
15+
return ans;
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)