human
Longest suffix such that occurrence of each character is less than N after deleting atmost K characters | Function to find the maximum length suffix in the string.
Length of the string.
Map to store the number of occurrence of character.
Loop to iterate string from the last character.
Condition to check if the occurrence of each character is less than given number.
Condition when character cannot be deleted.
Longest suffix.
Driver Code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to longest suffix such that occurrence of each character is less than N after deleting atmost K characters and the other steps required.
 def maximumSuffix ( s , n , k ) :
	i = len ( s ) - 1
	arr = [ 0 for i in range ( 26 ) ]
	suffix = " "
	while ( i > - 1 ) :
		index = ord ( s [ i ] ) - ord ( ' a ' ) ;
		if ( arr [ index ] < n ) :
			arr [ index ] += 1
			suffix += s [ i ]
			i -= 1
			continue
		if ( k == 0 ) :
			break
		k -= 1
		i -= 1
	suffix = suffix [ : : - 1 ]
	print ( suffix )
if __name__ == ' _ _ main _ _ ' :
	str = " iahagafedcba "
	n = 1
	k = 2
	maximumSuffix ( str , n , k )