Dsa
Trie
Warm-up
Bitwise Firewall
A firewall blocks packets if their binary header starts with a known malicious signature. You are given N bit-signatures and a single packet header string. Determine if the packet should be blocked.
Input Format:
1. An integer N (number of signatures).
2. N binary strings (signatures).
3. A single binary string (packet header).
Output Format:
'BLOCKED' if any signature is a prefix of the header, 'SAFE' otherwise.
Example:
Input:
2
101
111
1010011
Output:
BLOCKED
Key concepts
triebinarysecurity
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