Amazon on-site interview question
Anonymous User
1833

Hi, I got this in an interview and did not present a better solution. Can anyone help me with how this can be implemented with least time complexity. What is the better data structure for this?

Implement the below:

The user can post a message
Follow a user
Unfollow a user
Get 10 latest posts of user or the one he follows based on time(whichever are latest)
Given:
No need to assume a complex system. Assume everything the social network requires can fit in a machine.

I used a hash table and a priority queue, which does not seem to be a good solution. Let me know if you don't understand my question?

Comments (8)