easySliding WindowPure DSA~10 min
Max Consecutive Uptime
A health-check log records 1 for each minute a service was up and 0 for each minute it was down. Report the longest unbroken stretch of uptime.
Problem
Given a binary array status, return the maximum number of consecutive 1s.
Input
An array status of length n (1 ≤ n ≤ 10^5), each value 0 or 1.
Output
A single integer — the longest run of consecutive 1s.
Constraints
- 1 ≤ n ≤ 100,000
- Values are strictly 0 or 1
- A run resets at every 0
Examples
Example 1
Input
status = [1, 1, 0, 1, 1, 1]
Output
3
The final run of three 1s is the longest.
Example 2
Input
status = [0, 0, 0]
Output
0
No uptime minute at all.