Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Longest streak of active days

Python data engineering interview problem. Difficulty: intermediate. Pattern: Sliding Window. About 15 minutes. Part of the Pro drill bank.

A product's daily active flag is a list of 0/1 (or False/True). Retention wants the longest consecutive streak of active days.

Return the longest run of consecutive active days.

Requirements

  • A streak breaks on an inactive day.
  • Return a length, not the slice itself, unless tests say otherwise.

Constraints

  • flags: a sequence of active/inactive markers.
  • All inactive: streak 0.
  • All active: streak is the full length.

Examples

Input: longest_active_streak([1, 1, 0, 1, 1, 1]) Output: 3 This input follows the stated rules and produces this output.

Topics: lakebench, python, sliding-window.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Longest streak of active days

Interview-style drill: Given a list of daily activity flags, find the length of the longest streak of active days.

Return the longest run of consecutive active days.