All problems
Rollback Trigger Index
Problem
Find the first metric window that falls below a rollback threshold of baseline * (1 - max_degradation). Return the first failing index, or -1 when no window fails. Empty input returns -1.
Hint
An automated rollback fires as soon as a monitored window breaches its degradation budget.
Test cases
case 1
in: [[0.9,0.85,0.7,0.6],0.9,0.1]
expected: 2
case 2
in: [[0.9,0.88],0.9,0.05]
expected: -1
case 3
in: [[0.5],1,0.5]
expected: -1
case 4
in: [[],1,0.1]
expected: -1
case 5
in: [[0.8],0.9,0.1]
expected: 0
Starter codePython
def rollback_trigger_index(metrics, baseline, max_degradation):
# Your code here
pass5 test cases · run your code against them in the editor