Dsa
Trie
Easy
Word Search Prefix Count
You are given a list of words and a target prefix. Your task is to count how many words in the list start with the given prefix.
Input Format:
- The first line contains an integer n (1 <= n <= 1000), the number of words.
- The next n lines each contain a single word (1 <= length of word <= 100).
- The last line contains a string, the target prefix.
Output Format:
- Print the count of words that start with the target prefix.
Example:
Input:
5
apple
banana
apricot
avocado
berry
ap
Output:
3
Key concepts
trieprefixessearch
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