My simple accepted C++ solution
Idea: 1. Check the content if the current one is within sum +1, which is the total sum of all previous existing numbers. If yes, we proceed and update sum. If n
Idea: 1. Check the content if the current one is within sum +1, which is the total sum of all previous existing numbers. If yes, we proceed and update sum. If not, we patch one number that is within sum + 1. \n2. Keep updating the sum until it reaches n.\n   \n\n\n\n\n\n     int minPatches(vector<int>& nums, int n) {\n        \n        int len = nums.size();\n        int sum = 0;\n        int patch = 0;\n        int count = 0;\n\n        while (sum < n) {\n            if (count != len && nums[count] <= sum + 1) {\n                sum += nums[count];\n                count ++;\n            }\n            else {\n                patch ++;\n                if (sum > (INT_MAX - 1) / 2) {\n                    sum = INT_MAX;\n                }\n                else {\n                    sum = sum * 2 + 1;\n                }\n            }\n        }\n        \n        return patch;\n    }
['C++']