If the next character is also different in both the strings then these characters can be swapped
if ( i < n - 1 and str1 [ i + 1 ] != str2 [ i + 1 ] ) : NEW_LINE INDENT swap ( str1 [ i ] , str1 [ i + 1 ] ) NEW_LINE cost += 1 NEW_LINE DEDENT