All problems
Secretary Problem Threshold
Problem
In the secretary problem with n applicants, the optimal strategy rejects the first n / e applicants and then hires the next applicant better than all rejected ones. Return the number of applicants to skip, rounded to the nearest integer.
Return 0 for n <= 0.
Hint
The optimal fraction of applicants to skip approaches 1 / e.
Test cases
case 1
in: [3]
expected: 1
case 2
in: [10]
expected: 4
case 3
in: [100]
expected: 37
case 4
in: [0]
expected: 0
Starter codePython
import math
def secretary_threshold(n):
# Your code here
pass4 test cases · run your code against them in the editor