Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Consecutive Ones Counter

XPChallenge Points: 10
levelLevel: Easy

You are given an array nums consisting only of 0s and 1s.
Your task is to determine the length of the longest continuous sequence of 1s present in the array.

You must scan through the array and find the maximum number of consecutive 1s that appear without any 0 interrupting the sequence.

Example 1:

Input: nums = [1, 1, 1, 0, 1, 1]

Output: 3

Example 2:

Input: nums = [0, 1, 1, 1, 1, 0, 1]

Output: 4

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result