Skip to content
DeepForgeby svx
All problems
MediumProbabilitypr-030

Coupon Collector Expected Count

Problem

Expected number of draws to collect all n distinct coupons: n * H_n, where H_n = 1 + 1/2 + ... + 1/n.

Return 0.0 for n <= 0.

Hint

After k distinct coupons, the expected wait for a new one is n / (n - k).

Test cases

case 1
in: [1]
expected: 1
case 2
in: [2]
expected: 3
case 3
in: [3]
expected: 5.5
case 4
in: [10]
expected: 29.289682539682538
case 5
in: [52]
expected: 235.97828543626724
Starter codePython
def coupon_collector_expected(n):
    # Your code here
    pass

5 test cases · run your code against them in the editor