human
Check if a string can be transformed to another by sorting substrings | Function to check if str1 can be transformed to t by sorting substrings.
Occur [ i ] stores the indices of ( ' a ' + i ) in string s.
idx [ i ] stores the next available index of ( ' a ' + i ) in occur [ i ].
If this is not available anymore.
Conversion not possible.
If one of the smaller characters is available and occurs before.
Conversion not possible.
Print the answer.
Driver Code"
Solution in Python:

Give me a code to check if a string can be transformed to another by sorting substrings and the other steps required?
assistant
#Here is code to check if a string can be transformed to another by sorting substrings and the other steps required.
 def canTransform ( s , t ) :
	n = len ( s )
	occur = [ [ ] for i in range ( 26 ) ]
	for x in range ( n ) :
		ch = ord ( s [ x ] ) - ord ( ' a ' )
		occur [ ch ] . append ( x )
	idx = [ 0 ] * ( 26 )
	poss = True
	for x in range ( n ) :
		ch = ord ( t [ x ] ) - ord ( ' a ' )
		if ( idx [ ch ] >= len ( occur [ ch ] ) ) :
			poss = False
			break
		for small in range ( ch ) :
			if ( idx [ small ] < len ( occur [ small ] ) and occur [ small ] [ idx [ small ] ] < occur [ ch ] [ idx [ ch ] ] ) :
				poss = False
				break
		idx [ ch ] += 1
	if ( poss ) :
		print ( " Yes " )
	else :
		print ( " No " )
if __name__ == ' _ _ main _ _ ' :
	s = " hdecb "
	t = " cdheb "
	canTransform ( s , t )