Google Interview Question

Use a trie to solve this type of problem