Dsa
Trie
Medium
Domain Suggestion Tool
You are building a domain suggestion tool. Given a list of domain names and a partial domain name input, implement a function that returns all valid domain suggestions starting with the input. The suggestions should be unique and sorted in lexicographical order.
Input Format:
- The first line contains an integer n (1 ≤ n ≤ 10000), the number of domain names.
- The next n lines each contain a domain name (length ≤ 100).
- The last line contains a partial domain name input.
Output Format:
- Print each domain suggestion on a new line.
Example:
Input:
5
example.com
test.com
example.org
test.org
sample.com
example
Output:
example.com
example.org
Key concepts
triesearchstrings
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