human
Write me a code to sub and the other steps required given the following:
Sub | Function that returns true if every lowercase character appears atmost once.
Every character frequency must be not greater than one.
Function that returns the modified good string if possible.
If the length of the string is less than n.
Sub - strings of length 26.
To store frequency of each character.
Get the frequency of each character in the current sub - string.
Check if we can get sub - string containing the 26 characters all.
Find which character is missing.
Fill with missing characters.
Find the next missing character.
Return the modified good string.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to sub and the other steps required.
 def valid ( cnt ) :
	for i in range ( 0 , 26 ) :
		if cnt [ i ] >= 2 :
			return False
	return True
def getGoodString ( s , n ) :
	if n < 26 :
		return " - 1"
	for i in range ( 25 , n ) :
		cnt = [ 0 ] * 26
		for j in range ( i , i - 26 , - 1 ) :
			if s [ j ] != ' ? ' :
				cnt [ ord ( s [ j ] ) - ord ( ' a ' ) ] += 1
		if valid ( cnt ) :
			cur = 0
			while cur < 26 and cnt [ cur ] > 0 :
				cur += 1
			for j in range ( i - 25 , i + 1 ) :
				if s [ j ] == ' ? ' :
					s [ j ] = chr ( cur + ord ( ' a ' ) )
					cur += 1
					while cur < 26 and cnt [ cur ] > 0 :
						cur += 1
			return ' ' . join ( s )
	return " - 1"
if __name__ == " _ _ main _ _ " :
	s = " abcdefghijkl ? nopqrstuvwxy ? "
	n = len ( s )
	print ( getGoodString ( list ( s ) , n ) )