human
String which when repeated exactly K times gives a permutation of S | Function to return a string which when repeated exactly k times gives a permutation of s.
size of string.
to frequency of each character.
get frequency of each character.
to store final answer.
check if frequency is divisible by k.
add to answer.
if frequency is not divisible by k.
Driver code.
function call"
Solution in Python:
assistant
#Here is code to string which when repeated exactly K times gives a permutation of S and the other steps required.
 def K_String ( s , k ) :
	n = len ( s )
	fre = [ 0 ] * 26
	for i in range ( n ) :
		fre [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
	str = " "
	for i in range ( 26 ) :
		if ( fre [ i ] % k == 0 ) :
			x = fre [ i ] // k
			while ( x ) :
				str += chr ( i + ord ( ' a ' ) )
				x -= 1
		else :
			return " - 1"
	return str
if __name__ == " _ _ main _ _ " :
	s = " aabb "
	k = 2
	print ( K_String ( s , k ) )