Search
⌘K
Get Premium
Leetcode 1785. Minimum Elements to Add to Form a Given Sum
Given nums, limit, and goal, find the minimum number of elements (each with absolute value ≤ limit) to add so the array sum equals goal — equivalently compute the difference goal - sum(nums) and return the smallest k such that k*limit covers the absolute difference (i.e., ceil(|diff|/limit)).
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.