Dsa
Trie
Hard
Perform Regex Search in a Dictionary
You are given a dictionary of words and a regex pattern. Your task is to determine how many words from the dictionary match the regex pattern using a trie. Input format: The first line contains an integer n (1 ≤ n ≤ 1000) representing the number of words. The next n lines contain the dictionary words (1 ≤ length of word ≤ 100). The last line contains the regex pattern. Output format: Print the count of words that match the regex pattern. Example: Input: 3
bat
bar
baz
b.*
Output: 3
Key concepts
trieregexsearch operations
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