class Solution { public int findMaxConsecutiveOnes(int[] nums) { int ans=0; int count=0; for (int i = 0; i < nums.length; i++) { if(nums[i]==1) count++; else{ if(ans<count) ans=count; count=0; } } if(ans<count) ans=count; return ans; } }
class Solution { public int findMaxConsecutiveOnes(int[] nums) { int ans=0; int count=0; for (int i = 0; i < nums.length; i++) { if(nums[i]==1) count++; else{ if(ans<count) ans=count; count=0; } } if(ans<count) ans=count; return ans; } }