2357. Make Array Zero by Subtracting Equal Amounts ¶ Time: $O(n)$ Space: $O(n)$ C++JavaPython 1 2 3 4 5 6 7class Solution { public: int minimumOperations(vector<int>& nums) { unordered_set<int> seen(nums.begin(), nums.end()); return seen.size() - seen.contains(0); } }; 1 2 3 4 5 6class Solution { public int minimumOperations(int[] nums) { Set<Integer> seen = Arrays.stream(nums).boxed().collect(Collectors.toSet()); return seen.size() - (seen.contains(0) ? 1 : 0); } } 1 2 3class Solution: def minimumOperations(self, nums: list[int]) -> int: return len(set(nums) - {0})