Got this question recently in the onsite round.
We are implementing a service for photo app, to track photo views and tell you which photo ids are most viewed. Ids are simple integers. Candidates need to implement this interface.
//Called when this photo id is viewed once
void hit(int photoId);
//return the M photo ids with the most views, in order.
List mostViewed(int M);