https://leetcode.com/problems/patching-array/?tab=Description
好题目啊,下面的解法绝顶聪明:
https://discuss.leetcode.com/topic/35494/solution-explanation
int minPatches(vector<int>& nums, int n) { long miss = 1, added = 0, i = 0; while (miss <= n) { if (i < nums.size() && nums[i] <= miss) { miss += nums[i++]; } else { miss += miss; added++; } } return added; }