human
Minimum cost to convert one given string to another using swap , insert or delete operations | Function to find the minimum cost to convert a to b.
Stores the frequency of string a and b respectively.
Store the frequencies of characters in a.
Store the frequencies of characters in b.
Minimum cost to convert A to B.
Find the minimum cost.
Print the minimum cost.
Driver Code.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to minimum cost to convert one given string to another using swap , insert or delete operations and the other steps required.
 def minimumCost ( a , b ) :
	fre1 = [ 0 ] * ( 256 )
	fre2 = [ 0 ] * ( 256 )
	for c in a :
		fre1 [ ord ( c ) ] += 1
	for c in b :
		fre2 [ ord ( c ) ] += 1
	mincost = 0
	for i in range ( 256 ) :
		mincost += abs ( fre1 [ i ] - fre2 [ i ] )
	print ( mincost )
if __name__ == ' _ _ main _ _ ' :
	A = "1AB + - "
	B = " cc "
	minimumCost ( A , B )