CERIDIAN Hiring Off-Campus OA 2024 | Make Array Zero by Subtracting Equal Amounts | HashSet Approach

Question · Posted Jun 2026

Problem Statement You are given a non-negative integer array nums. In one operation: Choose a positive integer x such that x is less than or equal to the smallest non-zero element in the array. Subtract x from every non-zero element in the array. Return the minimum number of operations required to make all elements of the array equal to zero. Example 1 Input: nums = [1,5,0,3,5] Output: 3 Explanation Initial Array: [1,5,0,3,5] Operation 1: Choose x = 1 [0,4,0,2,4] Operation ...

The full answer & interview discussion are available to premium members.

Log in Create a free account