Sample index from weighted probability distribution | LinkedIn Interview Question