Search⌘ K
AI Features

Solution: Max Consecutive Ones

Explore how to solve the max consecutive ones problem by tracking essential information in a binary array. This lesson teaches you to maintain current and maximum streaks of ones efficiently in a single traversal, helping you master the pattern for similar coding challenges.

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 ...