Keyword Search

Solve an easy-level problem of searching a keyword in a list of strings using tries.

Problem statement

Given two lists of words (strings), for each word in the second list, identify if the word appears as either a complete word or a prefix of any word in the first list. If it's present as a complete word, print "word". If it's present as a prefix, print "prefix". If it isn't present as either a complete word or a prefix, print "not-found".

Example 1

Sample input

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy