Pergunta de entrevista da empresa X

Find a weighted probability given an array of doubles that stores the probabilities as doubles.