human
Check if a two character string can be made using given words | Function to check if str can be made using given words.
If str itself is present.
Match first character of str with second of word and vice versa.
If both characters found ..
Driver Code"
Solution in Python:
assistant
#Here is code to check if a two character string can be made using given words and the other steps required.
 def makeAndCheckString ( words , str ) :
	n = len ( words )
	first = second = False
	for i in range ( n ) :
		if words [ i ] == str :
			return True
		if str [ 0 ] == words [ i ] [ 1 ] :
			first = True
		if str [ 1 ] == words [ i ] [ 0 ] :
			second = True
		if first and second :
			return True
	return False
str = ' ya '
words = [ ' ah ' , ' oy ' , ' to ' , ' ha ' ]
if makeAndCheckString ( words , str ) :
	print ( ' YES ' )
else :
	print ( ' NO ' )