#NEWLINE# def minPatches( self , nums , n ) : #NEWLINE# #INDENT# '\n        :type nums: List[int]\n        :type n: int\n        :rtype: int\n        ' #NEWLINE# ( patch , miss , i ) = ( 0 , 1 , 0 ) #NEWLINE# while ( miss <= n ) : #NEWLINE# #INDENT# if ( ( i < len ( nums ) ) and ( nums [ i ] <= patch ) ) : #NEWLINE# #INDENT# miss += nums [ i ] #NEWLINE# i += 1 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# miss += miss #NEWLINE# patch += 1 #NEWLINE# #UNINDENT# #UNINDENT# return patch