charges[i] is the battery level of device i in percent. A technician walks from left to right and, for each device:
- if its charge is above zero, the device is checked, and **every device to its right** loses 1 percent of charge (never going below zero);
- if its charge is zero, the device is skipped and nothing changes.
Return the number of devices that get checked.charges=[2, 1, 3, 0, 2] → 2
Device 0 is checked and the later charges become [0, 2, 0, 1]. Device 1 is skipped, device 2 is checked, leaving [0, 0]. Devices 3 and 4 are empty. Two devices are checked.
charges=[0, 5, 5] → 2
Device 0 is empty; devices 1 and 2 are checked, the last one still holding 4 after the first check.
charges=[1, 1, 1, 1] → 1
The very first check drains every other device to zero.
charges=[2, 1, 3, 0, 2]
2
Run checks the first 3 tests in your browser. Submit checks all 110 tests on the server, hidden ones included.