Search⌘ K
AI Features

Solution: Max Consecutive Ones

Explore how to identify and track the longest sequence of consecutive ones in a binary array. This lesson teaches you to maintain a current count and a maximum count through a single traversal, helping you understand the knowing what to track pattern for optimal problem solving.

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