题目:
题解:
class Solution {public int minPatches(int[] nums, int n) {int patches = 0;long x = 1;int length = nums.length, index = 0;while (x <= n) {if (index < length && nums[index] <= x) {x += nums[index];index++;} else {x *= 2;patches++;}}return patches;}
}