Dsa
Trie
Medium
Unique Prefix Finder
Develop a system to find all unique prefixes in a list of strings that can uniquely identify each string.
Input:
- The first line contains an integer n, the number of strings.
- The next n lines each contain one string (1 <= |string| <= 100).
Output:
- Print each string followed by its unique prefix.
Example:
Input:
4
apple
appetizer
application
banana
Output:
apple a
appetizer app
application appli
banana b
Key concepts
triestringprefix uniqueness
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