Question bank › Trie
Dsa Trie Medium

Unique Prefix Count

Given a list of words, create a trie to find out how many unique prefixes exist for each word. For each word, output the number of unique prefixes that can uniquely identify it from the other words in the list. Input Format: - First line contains a space-separated list of words. Output Format: - For each word, print the number of unique prefixes on a new line. Example: Input: apple app banana band Output: 3 1 3 2

Key concepts

trieprefixcounting

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.