K10

Longest Continuous Streaming Buffer

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: NUMERIC

Problem Statement & Objective

A video platform measures buffer health second-by-second during live playback. A value of 1 represents steady uninterrupted playback, while 0 indicates a buffering stall or packet drop. Given the binary buffer history array, return the length of the LONGEST continuous sequence of 1s (uninterrupted streaming seconds).

Function Signature (Python)

longest_consecutive_ones(packets: list[int]) -> int

Input & Output Contract

Output Rule:Maximum integer length of consecutive 1s. Returns 0 if no 1s exist.

System Constraints

0 <= paketler.length <= 10^5
paketler[i] in {0, 1}

Example Execution Walkthrough

paketler = [1, 1, 0, 1, 1, 1, 0, 1]
streaks: 2, 3, 1 -> max is 3

Example Test Scenarios (3)

Example 1
Input:[[1,1,0,1,1,1,0,0,1]]
Expected Output:3
Example 2: Başta 4 Kesintisiz
Input:[[1,1,1,1,0,1]]
Expected Output:4
Example 3: İki Eşit Blok
Input:[[0,1,1,0,1,1]]
Expected Output:2
Loading Python Editor...
Input Parameters
[
  [
    1,
    1,
    0,
    1,
    1,
    1,
    0,
    0,
    1
  ]
]
Expected Output
3