Simple C++ solution
\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long maxReach = 0;\n        int ans = 0;\n        for(int i = 0; maxRe
```\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long maxReach = 0;\n        int ans = 0;\n        for(int i = 0; maxReach < n;) {\n            if(i < nums.size() && nums[i] <= (maxReach + 1)) {\n                maxReach = maxReach + nums[i];\n                i++;\n            } else {\n                maxReach = maxReach + maxReach + 1;\n                ans++;\n            }\n        }\n        return ans;\n    }\n};\n```
[]