human
Check if string follows order of characters defined by a pattern or not | Set 1 | Function to check if characters in the input string follows the same order as determined by characters present in the given pattern.
len stores length of the given pattern.
if length of pattern is more than length of input string , return false.
.
x , y are two adjacent characters in pattern.
find index of last occurrence of character x in the input string.
find index of first occurrence of character y in the input string.
return false if x or y are not present in the input string OR last occurrence of x is after the first occurrence of y in the input string.
return true if string matches the pattern.
Driver Code"
Solution in Python:

=====
What is a code to check if string follows order of characters defined by a pattern or not and the other steps required?
assistant
#Here is code to check if string follows order of characters defined by a pattern or not and the other steps required.
 def checkPattern ( string , pattern ) :
	l = len ( pattern )
	if len ( string ) < l :
		return False
	for i in range ( l - 1 ) :
		x = pattern [ i ]
		y = pattern [ i + 1 ]
		last = string . rindex ( x )
		first = string . index ( y )
		if last == - 1 or first == - 1 or last > first :
			return False
	return True
if __name__ == " _ _ main _ _ " :
	string = " engineers ▁ rock "
	pattern = " gsr "
	print ( checkPattern ( string , pattern ) )