status[i] is 1 if the server was up in minute i, else 0. You may retroactively repair at most k down-minutes (turn 0 into 1). Return the longest run of consecutive 1s achievable.
Signature
longestUptime(status: int[], k: int) → intExample 1
status = [1,1,1,0,0,0,1,1,1,1,0]
k = 2
output = 6
repair two zeros → 6
Example 2
status = [0,0,0]
k = 0
output = 0
Constraints
1 ≤ n ≤ 10^50 ≤ k ≤ n
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).