Skip to content
LC-2357 Easy LeetCode

2357. Make Array Zero by Subtracting Equal Amounts

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 73% Topics: Array, Hash Table, Greedy, Sorting, Heap (Priority Queue), Simulation
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

# hash table
class Solution(object):
    def minimumOperations(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        return len({x for x in nums if x})

Solution from kamyu104/LeetCode-Solutions · MIT

Similar questions