Hi, got an interesting question in Phone screen interview. Hopefully it will help someone. Trying to share the idea of the question. the actual language might be different in the question.
Linked has organised a fair. Based on some good action a linkedin member will be given 1 ticket. Based on some other bad action, a ticket will be taken from the member. Implement three methods addTicket(memberId) , removeTicket(memberId) and getRandom().
getRandom() should pick a member with weighted probability based on number of tickets a memeber has. Example if a member has 5 tickets and another one has 1 ticket, then the probability of the member with 5 tickets is higher than the one with 1 ticket. All 3 functions should be O(1) average case.
Its a variation of Insert Delete getRandom question
Hope it helps.