human
Check if the given string of words can be formed from words present in the dictionary | Function to check if the word is in the dictionary or not.
map to store all words in dictionary with their count.
adding all words in map.
search in map for all words in the sentence.
all words of sentence are present.
Driver Code.
Calling function to check if words are present in the dictionary or not"
Solution in Python:
assistant
#Here is code to check if the given string of words can be formed from words present in the dictionary and the other steps required.
 def match_words ( dictionary , sentence , n , m ) :
	mp = dict ( )
	for i in range ( n ) :
		mp [ dictionary [ i ] ] = mp . get ( dictionary [ i ] , 0 ) + 1
	for i in range ( m ) :
		if ( mp [ sentence [ i ] ] ) :
			mp [ sentence [ i ] ] -= 1
		else :
			return False
	return True
dictionary = [ " find " , " a " , " geeks " , " all " , " for " , " on " , " geeks " , " answers " , " inter " ]
n = len ( dictionary )
sentence = [ " find " , " all " , " answers " , " on " , " geeks " , " for " , " geeks " ]
m = len ( sentence )
if ( match_words ( dictionary , sentence , n , m ) ) :
	print ( " YES " )
else :
	print ( " NO " )