Dsa
Hashing
Easy
Serial Compatibility
Two hardware serial numbers are 'compatible' if they have the same length and differ by exactly one character at the same position. Given a list of N unique serial numbers, find the total number of compatible pairs.
Input Format:
- Line 1: Integer N.
- Next N lines: Unique serial number strings (all same length).
Output Format:
- A single integer representing the number of compatible pairs.
Example:
Input:
3
abc
abd
acc
Output:
2
(Explanation: (abc, abd) differ at index 2. (abc, acc) differ at index 1.)
Key concepts
hashingstringswildcards
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