All problems
Secretary Optimal Success Probability
Problem
Exact optimal success probability for the secretary problem with n applicants, maximizing over the number of applicants to reject:
P(k) = (k - 1) / n * sum from j = k to n of 1 / (j - 1).
Return 1.0 for n = 1 and 0.0 for n <= 0.
Hint
The best applicant is hired when the first record after the rejection phase is the global best.
Test cases
case 1
in: [1]
expected: 1
case 2
in: [2]
expected: 0.5
case 3
in: [3]
expected: 0.5
case 4
in: [10]
expected: 0.39869047619047615
case 5
in: [100]
expected: 0.3710427787126428
Starter codePython
def secretary_success_probability(n):
# Your code here
pass5 test cases · run your code against them in the editor