Implement weighted random city and sparse dot product | Meta Interview Question