Most active user by distinct contacts, then top K
Users send each other messages, and a message between A and B counts as contact for both of them. Build a class with:
-
register(a, b): record a message betweenaandb. -
most_active_user(): return the user with the most distinct contacts, in O(1).
Follow-up: return the top k users, where k can change from one call to the next. Other reports framed it as tracking the most active users in a live stream of communication.
No answer yet. Write the first one; the best answer gets endorsed.
