Very Easy C++ Solution with Video Explanation
Video Explanation\nhttps://youtu.be/YPY6EOfYANY?si=6NQWVso6wi1OiFtU\n# Complexity\n- Time complexity:O(nums.size())\n Add your time complexity here, e.g. O(n) \
# Video Explanation\nhttps://youtu.be/YPY6EOfYANY?si=6NQWVso6wi1OiFtU\n# Complexity\n- Time complexity:$$O(nums.size())$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        long long sum=0;\n        long long patches=0;\n        long long i=0;\n\n        while(sum<n){\n            if(i<nums.size() && nums[i]<=sum+1){\n                sum+=nums[i++];\n            }else{\n                patches++;\n                sum+=sum+1;\n            }\n        }\n        return patches;\n    }\n};\n```
['C++']