Tap here to switch tabs
Problem
Submissions

Problem: Count Tested Devices After Test Operations

Try to solve the Count Tested Devices After Test Operations problem.

Statement

You are given an integer array batteryPercentages of length n, where batteryPercentages[i] represents the battery percentage of the device at index i.

Your task is to inspect each device sequentially from index 00 to n −1- 1 by applying the following operations:

  • If batteryPercentages[i] > 0:

    • Increment the total number of tested devices.

    • For every subsequent device at index j where i <j<< j < n, decrease its battery percentage by 11, such that batteryPercentages[j] becomes max⁡(0,\max(0, batteryPercentages[j] −1)- 1).

  • If batteryPercentages[i] =0= 0, move to the next device without making any changes.

Return the total count of devices that are tested after processing all devices.

Constraints:

  • 1≤1 \leq n ==== batteryPercentages.length ≤100\leq 100

  • 0≤0 \leq batteryPercentages[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Tested Devices After Test Operations

Try to solve the Count Tested Devices After Test Operations problem.

Statement

You are given an integer array batteryPercentages of length n, where batteryPercentages[i] represents the battery percentage of the device at index i.

Your task is to inspect each device sequentially from index 00 to n −1- 1 by applying the following operations:

  • If batteryPercentages[i] > 0:

    • Increment the total number of tested devices.

    • For every subsequent device at index j where i <j<< j < n, decrease its battery percentage by 11, such that batteryPercentages[j] becomes max⁡(0,\max(0, batteryPercentages[j] −1)- 1).

  • If batteryPercentages[i] =0= 0, move to the next device without making any changes.

Return the total count of devices that are tested after processing all devices.

Constraints:

  • 1≤1 \leq n ==== batteryPercentages.length ≤100\leq 100

  • 0≤0 \leq batteryPercentages[i] ≤100\leq 100