A concrete example to work down the algorithm
\nThink it reversely: the maximum value we can form based on a given set of numsers?\nif for a give set [1, ..., k], and anything less or equal to k is already 
\nThink it reversely: the maximum value we can form based on a given set of numsers?\nif for a give set [1, ..., k], and anything less or equal to k is already covered. then anything [k+1 .... k + k) must also be covered! In another word, if we have k and all value before k is covered, then the later part [k, 2*k) is also covered.\n**This is the most important observation.** coverage is just symmetric around the largest item in the array! \nthe reason why 2k is not covered is because each element can only be pick only one time.\n\ne.g. [1, 2, 4] , since all value between [1, 4] is covered, this array will also cover [5, 8), the whole coverage is [1, 8).\ntherefore, for this array, if we ask for a target value that is between [8, 16) to be covered, we just need to add 8 to the array.\n\nNow,  we want a coverage to N, how should we approach to it?\nwe just need to scan the array and keep increasing our coverage until it >= N.\n\nexample:\n`[1, 2, 4, 13, 43], n = 100`\nprobable missing starts at 1, we encounter first item nums[0] = 1, it can cover `[1, 2)`\nincrease probable missing to nums[0] + missing = 2; next iteration, we encounter second item nums[1] = 2, it can cover `[1, 2 * nums[1])`\nincrease probable missing to nums[1] + missing = 4; next iteration, encounter `nums[2]  = 4`, covered, it can cover `[1, 4*nums[2])` = `[1, 8)`\nincrease probable missing to nums[2] + missing = 8, next iteration, encounter `nums[3] = 13`, 13 is not covered!, so we must add 8 to the array!\n    when we add 8 to the array, the coverage will become `2*8 = 16` (right open range), and since we have 13, we can extend the coverage to `16 + 13 = 29`. literally, `[1, 29)`\nso the next probable missing number should be 29; next searching iteration, encounter 43, not covered! so we add 29.\nand the coverage is extended to` [1, 43 + 29*2)` =  `[1, 101)`, we are done!\n\n\n```cpp\nint minPatches(vector<int>& nums, int n) {\n    int missing = 1, patches = 0, int i = 0;\n    while (missing <= n) {\n        if (i < nums.size() && nums[i] <= missing) {\n            missing += nums[i++];\n        } else {\n            missing += missing;\n            patches++;\n        }\n    }\n    return pathces;\n}\n```\n\n
[]