# Max Consecutive Ones

Given a binary array, find the maximum number of consecutive 1s in this array.

**Example 1:**

```
Input:
 [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.
```

## 题目大意：

给定一个二进制数组，计算数组中出现的最大连续1的个数。

**注意：**

* 输入数组只包含0和1
* 数组长度是正整数并且不会超过10000

## 解题思路：

一趟遍历+计数器

```
class Solution(object):
    def findMaxConsecutiveOnes(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        maxnumber = 0
        count = 0
        for i in xrange(len(nums)):
            if nums[i] == 1:
                count += 1
                maxnumber = max(maxnumber, count)
            else:
                count = 0
        return maxnumber
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rachel2011.gitbook.io/leetcode_cc150/leetcode/max-consecutive-ones.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
