We’re preparing your current view and syncing the latest data.
Maximum Consecutive Ones
gfgGiven a binary array, find the maximum number of consecutive 1s in the array.
An array of integers nums containing only 0s and 1s.
An integer representing the maximum number of consecutive 1s in the array.
1 <= nums.length <= 10^5 nums[i] is either 0 or 1.
Example 1
Input
[1,1,0,1,1,1]
Output
3
Explanation
The longest run of 1s is three.