Dsa
Trie
Medium
Phone Number Prefixes
A telecommunications company wants to check if any of its customer phone numbers can be a prefix of another. Create a program that reads a list of phone numbers and determines if any number is a prefix of another. If so, print that number as a prefix; otherwise, print 'No prefixes found'.
Input:
The first line contains an integer N (1 <= N <= 10000), the number of phone numbers.
The next N lines each contain a phone number (1 <= length <= 15, composed of digits only).
Output:
If any number is a prefix of another, print the prefix number. If no prefixes found, print 'No prefixes found'.
Example:
Input:
3
1234567890
1234
5678901234
Output:
1234
Key concepts
triephone numberprefix checking
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