Question bank › Trie
Dsa Trie Medium

Store and Search Contacts

Implement a contact book using a trie. Your program should read a set of contact names from the first line of input, followed by queries, each on a new line. For each query, return the count of names that start with the query string. If no names match, return 0. Input Format: - First line contains a space-separated list of contact names. - Subsequent lines contain queries. Output Format: - For each query, print the count of matching names on a new line. Example: Input: Alice Bob Charlie AliceBob Ali A Bob Zoe Output: 2 3 1 0

Key concepts

triestringssearch

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.