Employeur impliqué
How to randomly select a number with equal probability from an array with unknown size?
Utilisateur anonyme
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.
Tenez-vous au courant des dernières opportunités et profitez de conseils d’initiés en suivant les entreprises de vos rêves.
Obtenez des recommandations et des mises à jour personnalisées en démarrant vos recherches.