LeetCode: Make Array Zero by Subtracting Equal Amounts Solution

Count non-zero unique numbers

Approach

We will notice that on every operation, smallest number (other than 0) will be subtracted

Implementation

1var minimumOperations = function (nums) {
2 return new Set(nums.filter(Boolean)).size
3}

References

Original problem

Comments

Loading comments...

Tags

leetcode

array

Next Post

LeetCode: Combination Sum

Recursively try all the possible cases

Previous Post

Yarn cache large disk usage

It took 30GB prior to the time I cleared the cache

HoningJS

Search Posts