Track the User with the Most Distinct Contacts: O(1) Query and Top-K for Changing k
Company: Google
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
Overview: Design a class that records undirected messages between users and returns the user who has talked with the most distinct people, then make that query constant time and add a top-K query whose k changes on every call. It tests deduplication with hash sets, space analysis of per-user sets, and incremental ranking structures.
Read the full Google Software Engineer interview experience this question came from