[LeetCode] Count Tested Devices After Test Operations

1 · · Dec. 10, 2023, 3:07 a.m.
10031. Count Tested Devices After Test Operations You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices. Your task is to test each device i in order from 0 to n - 1, by performing the following test operations: If batteryPercentages[i] is greater than 0 : Increment the count of tested devices. Decrease the battery percentage of all devices with indices j in the range [i + 1, n - 1] by 1, ensuring their battery perce...