beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```javascript []\n/**\n * @param {number[]} nums\n * @param {number} limit\n * @param {number} goal\n * @return {number}\n */\nvar minElements = function (nums, limit, goal) {\n  var sum = nums.reduce((a, b) => a + b);\n  if (sum == goal) return 0;\n  var diff = Math.abs(goal - sum);\n  var step = Math.abs(limit);\n\n  var counter = 0;\n\n  while (diff != 0) {\n    while (step > diff) {\n      step--;\n    }\n    var skip = Math.floor(diff / step);\n    diff -= step * skip;\n    counter += skip;\n  }\n  return counter;\n};\n```
['JavaScript']