赞
踩
题目:
题解:
- int minPatches(int* nums, int numsSize, int n) {
- int patches = 0;
- long long x = 1;
- int index = 0;
- while (x <= n) {
- if (index < numsSize && nums[index] <= x) {
- x += nums[index];
- index++;
- } else {
- x <<= 1;
- patches++;
- }
- }
- return patches;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。