Simple Python Solution
def minPatches(self, nums, n):\n        ans, nsum = 0, 0\n        nums.append(n+1)\n        for i in nums:\n            num = min(i,n+1)\n            while nsum
    def minPatches(self, nums, n):\n        ans, nsum = 0, 0\n        nums.append(n+1)\n        for i in nums:\n            num = min(i,n+1)\n            while nsum + 1 < num:\n                nsum += nsum + 1\n                ans += 1\n            nsum += num\n        return ans
['Python']