Question bank › Trie
Dsa Trie Warm-up

Find Word Patterns

You are tasked with identifying words that match a given pattern using a trie. The pattern consists of characters and wildcards where a wildcard can match any character. Implement a trie that can insert words and allow for querying with patterns. The input will consist of commands: 1. 'ADD <word>' - Add a word to the trie. 2. 'MATCH <pattern>' - Find all words in the trie that match the given pattern. A wildcard is denoted by '*' which can match any character. For each 'MATCH' command, output the matching words in alphabetical order. Example: INPUT: ADD cat ADD bat ADD rat MATCH c*t MATCH b*t OUTPUT: cat bat

Key concepts

triestring-patternssearch

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.