✅ Easy C++ Solution
Code\n\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long int sum = 0;\n        int cnt = 0;\n        int i = 0;\n   
# Code\n```\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long int sum = 0;\n        int cnt = 0;\n        int i = 0;\n        while(sum < n)\n        {\n            if(i<nums.size() && nums[i] <= sum+1)\n            {\n                sum = sum + nums[i++];\n            }\n            else\n            {\n                cnt++;\n                sum = sum * 2 + 1;\n            }\n        }\n        return cnt;\n    }\n};\n```
['C++']