Max Consecutive Ones

给一个数组, 找出最长的连续的1. 经典dp算法.

public class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
        int max = 0;
        int cur = 0;
        for(int n : nums){
            if(n == 0)
                cur = 0;
            else
                cur++;
            max = Math.max(max,cur);
        }
        return max;
    }
}