Shortest Solution | C++ | greedy
\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        int patches = 0, i = 0, sz = nums.size();\n        long count = 1;\n       
```\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        int patches = 0, i = 0, sz = nums.size();\n        long count = 1;\n        while (count <= n) {\n            \n            if (i < sz && nums[i] <= count) \n                count += nums[i++];\n            \n            else {\n                count *= 2;\n                patches++;\n            }\n        }\n        \n        return patches;\n    }\n};\n```
['Greedy', 'C']