Trains the technique from
LeetCode 485Max Consecutive OnesThis 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 solar farm polls its panels along one long row and hands you the reply as status, listed in the order the panels sit on the row. status[i] is 1 when panel i answered and 0 when it did not.
A crew wants to know the widest stretch of neighbouring panels that all answered. Return the number of panels in the longest stretch that contains no silent panel, or 0 when no panel answered at all.
Example 1
The first three panels answer in a row. The pair at the end is only two wide.
Example 2
The stretch runs to the end of the row, so it still counts as four panels.
Example 3
Nothing answered, so there is no stretch to measure.
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_online_run(status: list[int]) -> int:public int longestOnlineRun(int[] status)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.