2960. Count Tested Devices After Test Operations

  Рет қаралды 57

CodeVia

CodeVia

7 ай бұрын

2960. Count Tested Devices After Test Operations #leetcode #googleinterview #javainterviewquestions #googleinterview #microsoftinterview #java #javaprogramming #fang
leetcode.com/problems/count-t...
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 percentage never goes below 0, i.e, batteryPercentages[j] = max(0, batteryPercentages[j] - 1).
Move to the next device.
Otherwise, move to the next device without performing any test.
Return an integer denoting the number of devices that will be tested after performing the test operations in order.

Пікірлер: 1
@bsrayat8200
@bsrayat8200 7 ай бұрын
Great!
Nature's Incredible ROTATING MOTOR (It’s Electric!) - Smarter Every Day 300
29:37
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
A teacher captured the cutest moment at the nursery #shorts
00:33
Fabiosa Stories
Рет қаралды 40 МЛН
Double Stacked Pizza @Lionfield @ChefRush
00:33
albert_cancook
Рет қаралды 90 МЛН
Summer shower by Secret Vlog
00:17
Secret Vlog
Рет қаралды 11 МЛН
The moment we stopped understanding AI [AlexNet]
17:38
Welch Labs
Рет қаралды 798 М.
1636  Sort Array by Increasing Frequency
9:33
NO
Рет қаралды 25
Is Linux better than Windows?
5:21
Apna College
Рет қаралды 825 М.
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22