Given a binary array nums, return the maximum number of consecutive 1's in the array.

&nbsp;
Example 1:

Input: nums = [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.


Example 2:

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


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 105
	nums[i] is either 0 or 1.


class Solution:
    def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
        
        count = maxCount = 0
        
        for i in range(len(nums)):
            if nums[i] == 1:
                count += 1
            else:
                maxCount = max(count, maxCount)
                count = 0
                
        return max(count, maxCount)
class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        int new_max = 0;
        for(int i=0;i<nums.length;i++){
            if(nums[i]==1)
            {
                max++;
            }
            else{
                if(max>new_max){
                    new_max = max;
                }
                max = 0;
            }
        }
        if(max<new_max)
            return new_max;
        else
            return max;
    }
}
class Solution {
public:
    int findMaxConsecutiveOnes(vector<int>& nums)
    {
        int curr_count = 0;
        int max_count = 0;
        int i = 0;
        while(i < nums.size())
        {
            if(nums[i] == 1)
            {
                curr_count += 1;
                if(max_count < curr_count)
                    max_count = curr_count;                        
            }
            
            else
                curr_count = 0;
            i++;
        }
        return max_count;
    }
};
var findMaxConsecutiveOnes = function(nums) {
    let count =0
    let max =0
    for(let i=0; i<nums.length; i ++){
        if(nums[i]==1){
            count ++
        }
        if(nums[i]==0 || i==nums.length-1){
            max = Math.max(count,max)
            count = 0
        }
    }
    return max
};
Max Consecutive Ones