1. class Solution {
  2. public int findMaxConsecutiveOnes(int[] nums) {
  3. int max = 0;
  4. int consecutive_ones = 0;
  5. for(int i=0;i<nums.length;i++)
  6. {
  7. if(nums[i] == 0)
  8. {
  9. max = Math.max(consecutive_ones, max);
  10. consecutive_ones = 0;
  11. }
  12. else
  13. consecutive_ones++;
  14. }
  15. max = Math.max(consecutive_ones, max);
  16. return max;
  17. }
  18. }