Dsa
Trie
Easy
Distinct Suffix Counter
Given a list of words, your task is to count the number of distinct suffixes for each word in the list. A suffix is distinct if it has not appeared as a suffix of any other word.
Input:
- The first line contains an integer 'n' (1 <= n <= 1000) - the number of words.
- The next 'n' lines each contain a single word.
Output:
- Print 'n' integers, each representing the number of distinct suffixes for the corresponding word.
Example:
Input:
3
dog
log
doghouse
Output:
3
3
5
Key concepts
triesuffixcount
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