Easy to understand Greedy solution| Javascript | tc: O(n) | sc: O(1)
Complexity\n- Time complexity: O(N)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
# Complexity\n- Time complexity: $$O(N)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\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 = 0\n    for(var i = 0; i<nums.length; i++) sum += nums[i]\n    if(sum === goal) return 0\n    var diff = Math.abs(goal - sum)\n\n    if(diff <= limit) return 1\n\n    if(diff % limit == 0) return diff/limit\n    var ans = Math.floor(diff/limit) + 1\n    return ans\n\n};\n```
['Greedy', 'JavaScript']