489. Make all elements of Array Zero
0
Easy
Given a non-negative integer array nums, the task is to make all elements of the array equal to zero. In each operation, the following steps are performed:
1. Choose a positive integer x that is less than or equal to the smallest non-zero element in nums.
2. Subtract x from every positive element in nums.
The goal is to determine the minimum number of operations required to make every element in nums equal to zero.
Input Format
The first line contains an integer N, which represents the size of the array.
The second line consists of N space-separated integers, which represent the elements of the array.
Output Format
An integer representing the minimum number of operations required.
Example
Input
5
1 5 0 3 5
Output
3
Constraints
1 <= N <= 103
Loading...
View Submissions
Console