[LeetCode] Minimum Elements to Add to Form a Given Sum

1 · · March 7, 2021, 8:28 a.m.
1785. Minimum Elements to Add to Form a Given Sum You are given an integer array nums and two integers limit and goal. The array nums has an interesting property that abs(nums[i]) <= limit. Return the minimum number of elements you need to add to make the sum of the array equal to goal. The array must maintain its property that abs(nums[i]) <= limit. Note that abs(x) equals x if x >= 0, and -x otherwise. ...