Skip to content

Practice Make Array Zero by Subtracting Equal Amounts

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2357
LeetCode Problem

Make Array Zero by Subtracting Equal Amounts

Problem Statement

In one operation choose a positive integer no larger than the smallest positive element of nums, then subtract it from every positive element, leaving zeros unchanged. Return the fewest operations needed to make all elements zero.

Source: Make Array Zero by Subtracting Equal Amounts on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
nums = [1,5,0,3,5]
Output
3

# Example 2

Input
nums = [0]
Output
0

Constraints

1 <= nums.length <= 100
0 <= nums[i] <= 100

Related LeetCode Problems

Practice more problems similar to Make Array Zero by Subtracting Equal Amounts.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.