[JavaScript] Easy to understand - 1-line greedy
For this problem, the key point is that we could add multiple identical numbers, which means it\'s straightforward to solve it via greedy strategy.\n\njs\nconst
For this problem, the key point is that we could add multiple identical numbers, which means it\'s straightforward to solve it via greedy strategy.\n\n```js\nconst minElements = (nums, limit, goal) => {\n  let diff = goal;\n  for (let i = 0; i < nums.length; ++i) {\n    diff -= nums[i];\n  }\n  return Math.ceil(Math.abs(diff) / limit);\n};\n```\n\nAnd, sure, we can make it 1-line easily:\n\n```js\nconst minElements = (nums, limit, goal) => Math.ceil(Math.abs(nums.reduce((prev, cur) => prev - cur, goal) / limit));\n```
['JavaScript']