2960.统计已测试设备
链接:2960.统计已测试设备
难度:Easy
标签:数组、模拟
简介:返回一个整数,表示按顺序执行测试操作后 已测试设备 的数量。
题解 1 - python
- 编辑时间:2024-05-10
- 执行用时:54ms
- 内存消耗:16.46MB
- 编程语言:python
- 解法介绍:模拟。
class Solution:
    def countTestedDevices(self, batteryPercentages: List[int]) -> int:
        res = 0
        for i in range(len(batteryPercentages)):
            if batteryPercentages[i] > 0:
                for j in range(i + 1, len(batteryPercentages)):
                    batteryPercentages[j] -= 1
                res += 1
        return res