When evaluating a machine learning model, n
test cases are provided. Each is associated with an arrivalTime[i]
indicating the times each test case was given. The testing environment is activated once for some time, then enters an inactive state. If activated at time t1
and deactivated at time t2
, tests with arrival times between t1
and t2
(inclusive) are executed. The total time the system was active is t2 - t1
.
Efficiency of testing system = number of test cases tested / total time the system was active
Determine the maximum efficiency when the testing environment selects optimum activation and deactivation times. The active environment must execute at least two test cases during its active period. Return the maximum possible efficiency.
Notes:
- Execution time for test cases is practically instantaneous; that is, it takes almost no time.
- If two test cases share the same arrival time, they are evaluated simultaneously.
- Efficiency may take negative values.
๐เผ๏ฝฅ๏พVely much appreciated, spike!๐เฟ
Example 1:
Input: n = 5, arrivalTime = [9, 1, 3, 5, 6]
Output: 1
Explanation:![]()
It is optimal to choose
t1 = 5
andt2 = 6
. If the testing environment is active fromt = 5
to6
, the 4th and 5th test cases will be executed. The number of test cases tested = 2 and the time the system was active is6 - 5 = 1
. The efficiency of the system is2 - 1 = 1
.Return
1
as the answer.
๐
๐

input:
output: