Dsa
Trie
Easy
Binary IP Router
In networking, a router uses the Longest Prefix Match to determine where to send a packet. You are given a set of binary rules (prefix and destination). For a given binary IP, find the destination of the longest matching rule.
Example:
Input:
2
101 Alpha
10111 Beta
1
101110
Output:
Beta
Key concepts
triebinarylongest-prefix-match
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