Pergunta de entrevista da empresa Freshworks

Return a random value from array with probability proportional to its value