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

Aug 8, 2022

Recursively try all the possible cases

Previous Post

Yarn cache large disk usage

Jul 29, 2022

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

HoningJS

Search Posts