Easy to understand C++ solution beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \nIf the current sum < nums[i]-1, then we cannot create nums[i] using the sum, we need to
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf the current sum < nums[i]-1, then we cannot create nums[i] using the sum, we need to add sum+1 to the array,so next the sum becomes sum += sum + 1.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nEach time while adding a new number to the current sum, we want the sum to cover the number sum + 1, if the number is greater than sum + 1, then sum + 1 cannot be covered, so we need to add that number to the list, so we increment count, we also increment the current sum to sum = sum + sum + 1. We continue this operation until we cover all the elements.\n\n# Complexity\n- Time complexity:O(n)\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 count = 0;\n        long long sum = 0;\n        long long i = 0;\n        while(sum < n){\n            if(i<nums.size() && nums[i] <= (sum+1)){\n                sum += nums[i++];\n            }else{\n                count++;\n                sum += (sum + 1);\n            }\n        }\n        return count;\n    }\n};\n```
['C++']