[Python3] greedy
\n\nclass Solution:\n    def minPatches(self, nums: List[int], n: int) -> int:\n        ans = prefix = k = 0 \n        while prefix < n: \n            if k < le
\n```\nclass Solution:\n    def minPatches(self, nums: List[int], n: int) -> int:\n        ans = prefix = k = 0 \n        while prefix < n: \n            if k < len(nums) and nums[k] <= prefix + 1: \n                prefix += nums[k]\n                k += 1\n            else: \n                ans += 1\n                prefix += prefix + 1\n        return ans \n```
['Python3']