Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Note:
The input array will only contain 0 and 1.
The length of input array is a positive integer and will not exceed 10,000
解法1:O(N),一次遍历
dp的思想,dp[i] = dp[i - 1] + 1 if dp[i] == 1 else dp[i] = 0, 然后用一个res来记录当前遇到的最大值即可。
Java