If the flag is true and both pointers points to their end of respective strings then it is possible to transformed str1 into str2 , otherwise not .
if ( flag and ptr1 == len ( str1 ) and ptr2 == len ( str2 ) ) : NEW_LINE INDENT print ( " YES " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " NO " ) NEW_LINE DEDENT