human
Minimum substring flips required to convert a Binary String to another | Function to count the minimum number of reversals required to make the given binary strings s1 and s2 same.
Stores the minimum count of reversal of substrings required.
If the length of the strings are not the same then return - 1.
Iterate over each character.
If s1 [ i ] is not equal to s2 [ i ].
Iterate until s1 [ i ] != s2 [ i ].
Increment answer by 1.
Return the resultant count of reversal of subrequired.
Driver Code.
Function Call"
Solution in Python:
assistant
#Here is code to minimum substring flips required to convert a Binary String to another and the other steps required.
 def canMakeSame ( s1 , s2 ) :
	ans = - 1
	if ( len ( s1 ) != len ( s2 ) ) :
		return - 1
	N = len ( s1 )
	for i in range ( 0 , N ) :
		if ( s1 [ i ] != s2 [ i ] ) :
			while ( i < len ( s1 ) and s1 [ i ] != s2 [ i ] ) :
				i += 1
			ans += 1
	return ans
S1 = "100001"
S2 = "110111"
print ( canMakeSame ( S1 , S2 ) )