Description
Given a binary array, find the maximum number of consecutive 1s in this array.
Example
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.
Note
1.The input array will only contain 0 and 1.
2.The length of input array is a positive integer and will not exceed 10,000
Solution
|
|
Result
AC
Analyse
遍历的问题。
Optimization
|
|
Analyse
不影响可读性的情况下,更短的代码果然显得更美。
近期评论