2960. Count Tested Devices After Test Operations ¶ Time: $O(n)$ Space: $O(1)$ C++JavaPython 1 2 3 4 5 6 7 8 9 10 11 12class Solution { public: int countTestedDevices(vector<int>& batteryPercentages) { int ans = 0; for (const int batteryPercentage : batteryPercentages) if (batteryPercentage - ans > 0) ++ans; return ans; } }; 1 2 3 4 5 6 7 8 9 10 11class Solution { public int countTestedDevices(int[] batteryPercentages) { int ans = 0; for (final int batteryPercentage : batteryPercentages) if (batteryPercentage - ans > 0) ++ans; return ans; } } 1 2 3 4 5 6 7 8 9class Solution: def countTestedDevices(self, batteryPercentages: list[int]) -> int: ans = 0 for batteryPercentage in batteryPercentages: if batteryPercentage - ans > 0: ans += 1 return ans