Patching Array
题目描述
解题方法
Solution
class Solution(object):
def minPatches(self, nums, n):
"""
:type nums: List[int]
:type n: int
:rtype: int
"""
limit = 1
patch_add = 0
length = len(nums)
idx = 0
while limit <= n:
if idx < length and nums[idx] <= limit:
limit += nums[idx]
idx += 1
else:
limit += limit
patch_add += 1
return patch_add