Question bank › Trie
Dsa Trie Warm-up

The Librarian's Index

In a digital library, you are tasked with counting how many book titles start with a specific search string. You will be given a list of N book titles (single words) and a query prefix. Use a Trie to store the titles and efficiently answer the count. Input Format: 1. An integer N, the number of titles. 2. N titles, each on a new line. 3. A single string representing the search prefix. Output Format: A single integer representing how many titles start with that prefix. Example: Input: 4 apple apply apricot banana ap Output: 3

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