Trains the technique from
LeetCode 1004Max Consecutive Ones IIIThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A storage team keeps a nightly integrity log. checks holds one entry per night in chronological order: 1 means that night's snapshot was checked, 0 means the check was skipped.
There is spare capacity to go back and check at most k of the skipped nights, and the team may choose whichever skipped nights it likes.
Report the greatest number of neighbouring nights that can all end up checked once at most k retro-checks have been spent. Spare capacity may go unused, and the nights picked for a retro-check need not sit next to each other.
Example 1
Spending the single retro-check on night 2 leaves nights 0 through 4 all checked, five nights wide. Any six neighbouring nights here hold two gaps, which is one retro-check too many.
Example 2
Retro-checking nights 4 and 5 fills the only gaps inside nights 2 through 8, so seven neighbouring nights end up checked.
Example 3
Nothing was checked and there is no spare capacity, so no night can be part of a checked block.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def longest_verified_streak(checks: list[int], k: int) -> int:public int longestVerifiedStreak(int[] checks, int k)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.