Simple C++ O(N) solution
\nclass Solution {\npublic:\n    int minElements(vector<int>& nums, int limit, int goal) {\n        double sum = 0;\n        for (int i = 0; i < nums.size(); i+
```\nclass Solution {\npublic:\n    int minElements(vector<int>& nums, int limit, int goal) {\n        double sum = 0;\n        for (int i = 0; i < nums.size(); i++)   sum += nums[i];\n        double diff = goal - sum;\n        if (diff < 0) diff = (-1) * diff;\n        int count = diff / limit;\n        diff -= ((double)limit * (double)count);\n        if (diff > 0)  ++count;\n        \n        return count;\n    }\n};\n```
[]