Dsa
Trie
Hard
Network Prefix Shadowing
In network routing, a 'User' IP prefix is 'shadowed' if there exists an 'Admin' IP prefix that is either exactly the same or a shorter prefix of the User string. Given a list of Admin prefixes and a list of User prefixes (represented as binary strings), count how many User prefixes are shadowed by at least one Admin prefix.
Input Format:
1. An integer N (number of Admin prefixes).
2. N lines of binary strings (Admin).
3. An integer M (number of User prefixes).
4. M lines of binary strings (User).
Output Format: An integer representing the count of shadowed User prefixes.
Example:
Input:
1
101
2
1010
111
Output: 1
Explanation: '1010' is shadowed by '101' because '101' is a prefix of '1010'. '111' is not shadowed.
Key concepts
prefix-matchingnetwork-security
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