Practice Count Tested Devices After Test Operations
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Process batteryPercentages from left to right using their current battery percentages. If a device is positive, count it as tested and reduce every later device by 1, never below 0. If it is zero, skip it without reducing later devices. Return the number tested.
Source: Count Tested Devices After Test Operations on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
batteryPercentages = [1,1,2,1,3]
Output
3
# Example 2
Input
batteryPercentages = [0,1,2]
Output
2
Constraints
1 <= n == batteryPercentages.length <= 100
0 <= batteryPercentages[i] <= 100
Related LeetCode Problems
Practice more problems similar to Count Tested Devices After Test Operations.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.