Question d’entretien chez Google

How to randomly select a number with equal probability from an array with unknown size?

Réponse à la question d'entretien

Utilisateur anonyme

27 nov. 2010

Keep a variable as the return result and current size of the array. Update the result with probability size-1/size, when getting new number.