Dsa
Hashing
Hard
Common Login Patterns
You are given a list of login attempts. Each attempt consists of a username and IP address pair. Your task is to identify all usernames that have attempted to log in from the same IP address at least twice. Print these usernames in alphabetical order, each on a new line.
Input Format:
- The first line contains an integer n (1 <= n <= 10^5): number of login attempts.
- The following n lines contain a string username and string ip_address.
Output Format:
- Print each username that has multiple login attempts from the same IP address in alphabetical order.
Example:
Input:
5
user1 192.168.0.1
user2 192.168.0.2
user1 192.168.0.1
user2 192.168.0.2
user3 192.168.0.3
Output:
user1
user2
Key concepts
hashingsetspatterns
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