Pergunta de entrevista da empresa Tripadvisor

Randomly select distinct objects from a big array. What if you cannot change the order of the original array?

Resposta da entrevista

Sigiloso

6 de jul. de 2012

First question is classic random selection problem, which involves manipulation of the original array (shifting chosen ones to the end of the array). Second question: maintain a list of shifted elements in another set. Basically provides an override. Then use the same algorithm.