100% BEATS|| EASY MATHS SOLUTION
Intuition\nIt\'s totally a mathematics problem.In maths if you can achieve any combination certain sum,and get a number sum+1,then you can make any sum combinat
# Intuition\nIt\'s totally a mathematics problem.In maths if you can achieve any combination certain sum,and get a number sum+1,then you can make any sum combinations from 1 to sum*2+1\n\n# Approach\nIf the next element is not sum+1,then add sum+1 and your range becomes sum*2+1 else you can add smaller number to increase your range,but not a greater number than sum+1\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n\n# Code\n```\n#define ll long long\nclass Solution {\npublic:\n    int minPatches(vector<int>& nums, int n) {\n        int ans=0;ll ml=0;\n       for(int i=0;i<nums.size();i++){\n           if(nums[i]<=ml+1){\n               ml+=nums[i];\n           }\n           else{\n               while(nums[i]>ml+1){\n                   ml+=(ml+1);\n                   ans++;\n                   if(ml>=n)break;\n               }\n               ml+=nums[i];\n           }\n           if(ml>=n)break;\n       }\n       while(ml<n){\n           ml+=ml+1;\n           ans++;\n       }\n        return ans;\n    }\n};\n```
['C++']