Tap here to switch tabs
Problem
Submissions

Problem: Make Array Zero by Subtracting Equal Amounts

Make Array Zero by Subtracting Equal Amounts asks you to turn an integer array into all zeros, counting the fewest valid operations when each operation subtracts one positive amount from every positive element without making any element negative.

Statement

Given an integer array nums, you can perform the following operation any number of times.

In one operation, select a positive integer x such that at least one element of nums is nonzero, and for every index i where nums[i] > 0, replace nums[i] with nums[i] - x.

Return the minimum number of operations required to make every element in nums equal to 00.

Note: In each operation, x must be a positive value that does not make any currently positive element become negative.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Make Array Zero by Subtracting Equal Amounts

Make Array Zero by Subtracting Equal Amounts asks you to turn an integer array into all zeros, counting the fewest valid operations when each operation subtracts one positive amount from every positive element without making any element negative.

Statement

Given an integer array nums, you can perform the following operation any number of times.

In one operation, select a positive integer x such that at least one element of nums is nonzero, and for every index i where nums[i] > 0, replace nums[i] with nums[i] - x.

Return the minimum number of operations required to make every element in nums equal to 00.

Note: In each operation, x must be a positive value that does not make any currently positive element become negative.

Constraints:

  • 1≤1 \leq nums.length ≤100\leq 100

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