Question bank › Trie
Dsa Trie Warm-up

Count Distinct Prefixes

You are given a list of words, and your task is to count the number of distinct prefixes in those words. Build a trie to facilitate this. Each distinct prefix that appears in any word should be counted only once, regardless of how many words share the prefix. The output should be a single integer representing the count of distinct prefixes. Example: INPUT: apple app banana bat OUTPUT: 9

Key concepts

trieprefixescounting

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.