Search⌘ K
AI Features

Solution: Max Consecutive Ones

Explore how to determine the maximum number of consecutive ones in a binary array by tracking essential information. Learn to update current and maximum streaks in a single pass for an efficient solution. This lesson helps you implement the pattern of knowing what to track to solve similar frequency analysis problems.

Statement

You are given a binary array nums (an array that contains only 00s and 11s). Your task is to find the maximum number of consecutive 11s in the array and return it.

Constraints

  • 11 \leq ...