human
Give me a code to minimize count of given operations required to make two given strings permutations of each other and the other steps required given the following:
Minimize count of given operations required to make two given strings permutations of each other | Function to minimize the count of operations to make str1 and str2 permutations of each other.
Store the frequency of each character of str1.
Store the frequency of each character of str2.
Traverse the freq1 [ ] and freq2 [ ].
If frequency of character in str1 is greater than str2.
Otherwise.
Store sum of freq1 [ ].
Store sum of freq2 [ ].
Driver Code"
Solution in Python:
assistant
#Here is code to minimize count of given operations required to make two given strings permutations of each other and the other steps required.
 def ctMinEdits ( str1 , str2 ) :
	N1 = len ( str1 )
	N2 = len ( str2 )
	freq1 = [ 0 ] * 256
	for i in range ( N1 ) :
		freq1 [ ord ( str1 [ i ] ) ] += 1
	freq2 = [ 0 ] * 256
	for i in range ( N2 ) :
		freq2 [ ord ( str2 [ i ] ) ] += 1
	for i in range ( 256 ) :
		if ( freq1 [ i ] > freq2 [ i ] ) :
			freq1 [ i ] = freq1 [ i ] - freq2 [ i ]
			freq2 [ i ] = 0
		else :
			freq2 [ i ] = freq2 [ i ] - freq1 [ i ]
			freq1 [ i ] = 0
	sum1 = 0
	sum2 = 0
	for i in range ( 256 ) :
		sum1 += freq1 [ i ]
		sum2 += freq2 [ i ]
	return max ( sum1 , sum2 )
str1 = " geeksforgeeks "
str2 = " geeksforcoder "
print ( ctMinEdits ( str1 , str2 ) )