❇ minimum-elements-to-add👌 🏆O(N)❤️ Javascript🎯 Memory👀95.45%🕕 ++Explanation✍️ 🔴🔥 ✅ 👉 💪🙏
Time Complexity: O(N)\nSpace Complexity: O(1)\n\n\nvar minElements = function (nums, limit, goal) {\n    const sum = (function () {\n        let sum = 0;\n     
Time Complexity: O(N)\nSpace Complexity: O(1)\n\n```\nvar minElements = function (nums, limit, goal) {\n    const sum = (function () {\n        let sum = 0;\n        for (const iterator of nums) {\n            sum += iterator;\n        }\n        return sum;\n    })();\n    let diff = 0;\n    if ((sum < 0 && goal < 0) || (sum >= 0 && goal >= 0)) {\n        diff += Math.abs(sum - goal);\n    } else if (sum < 0 && goal > 0) {\n        diff += Math.abs(sum) + goal;\n    } else if (sum >= 0 && goal < 0) {\n        diff += Math.abs(goal) + sum;\n    }\n    return Math.ceil(diff / Math.abs(limit));\n};\n```
['JavaScript']