Longest Run of Healthy Servers After One Fixed-Length Repair

Asked at Amazon · Coding Questions · Difficulty: Medium · Last asked Nov 10, 2026

A monitoring log is a string of `0` and `1` characters, one per server: `1` means the server is healthy and `0` means it is faulty. You may run one repair operation at most. The operation picks a block of consecutive servers whose length is exactly `k` and makes every server in the block healthy. After the repair, you want the longest possible stretch of consecutive healthy servers.

Loading the problem…