human
Count characters to be shifted from the start or end of a string to obtain another string | Function to find the minimum cost to convert string A to string B.
Length of string.
Initialize maxlen as 0.
Traverse the string A.
Stores the length of substrings of string A.
Traversing string B for each character of A.
Shift i pointer towards right and increment length , if A [ i ] equals B [ j ].
If traverse till end.
Update maxlen.
Return minimum cost.
Driver Code.
Given two strings A and B.
Function call"
Solution in Python:

What is a code to count characters to be shifted from the start or end of a string to obtain another string and the other steps required?
assistant
#Here is code to count characters to be shifted from the start or end of a string to obtain another string and the other steps required.
 def minCost ( A , B ) :
	n = len ( A ) ;
	i = 0 ;
	maxlen = 0 ;
	while ( i < n ) :
		length = 0 ;
		for j in range ( 0 , n ) :
			if ( A [ i ] == B [ j ] ) :
				i += 1
				length += 1 ;
				if ( i == n ) :
					break ;
		maxlen = max ( maxlen , length ) ;
	return n - maxlen ;
if __name__ == ' _ _ main _ _ ' :
	A = " edacb " ;
	B = " abcde " ;
	print ( minCost ( A , B ) ) ;