<gouthampradhan>array_MaxConsecutiveOnesII_1.java
public int findMaxConsecutiveOnes(int[] nums) {
    int[] L = new int[nums.length];
    int[] R = new int[nums.length];
    boolean flag = false;
    int count = 0;
    int max = 0;
    for (int j = 0; j < nums.length; j++) {
      if (nums[j] == 1) {
        if (!flag) {
          flag = true;
        }
        count++;
        L[j] = count;
      } else {
        count = 0;
        flag = false;
        L[j] = count;
      }
      max = Math.max(max, count);
    }
    flag = false;
    count = 0;
    for (int j = nums.length - 1; j >= 0; j--) {
      if (nums[j] == 1) {
        if (!flag) {
          flag = true;
        }
        count++;
        R[j] = count;
      } else {
        count = 0;
        flag = false;
        R[j] = count;
      }
    }
    for (int i = 0; i < nums.length; i++) {
      if (nums[i] == 0) {
        int l = i == 0 ? 0 : L[i - 1];
        int r = i == nums.length - 1 ? 0 : R[i + 1];
        max = Math.max(max, l + r + 1);
      }
    }
    return max;
  }
public int sample_funcname ( int [ ] var_0 ) {
  int [ ] var_2 = new int [ var_0 . length ] ;
  int [ ] var_3 = new int [ var_0 . length ] ;
  boolean var_10 = false ;
  int var_6 = 0 ;
  int max = 0 ;
  for ( int var_8 = 0 ;
  var_8 < var_0 . length ;
  var_8 ++ ) {
    if ( var_0 [ var_8 ] == 1 ) {
      if ( ! var_10 ) {
        var_10 = true ;
      }
      var_6 ++ ;
      var_2 [ var_8 ] = var_6 ;
    }
    else {
      var_6 = 0 ;
      var_10 = false ;
      var_2 [ var_8 ] = var_6 ;
    }
    max = Math . max ( max , var_6 ) ;
  }
  var_10 = false ;
  var_6 = 0 ;
  for ( int var_8 = var_0 . length - 1 ;
  var_8 >= 0 ;
  var_8 -- ) {
    if ( var_0 [ var_8 ] == 1 ) {
      if ( ! var_10 ) {
        var_10 = true ;
      }
      var_6 ++ ;
      var_3 [ var_8 ] = var_6 ;
    }
    else {
      var_6 = 0 ;
      var_10 = false ;
      var_3 [ var_8 ] = var_6 ;
    }
  }
  for ( int var_12 = 0 ;
  var_12 < var_0 . length ;
  var_12 ++ ) {
    if ( var_0 [ var_12 ] == 0 ) {
      int var_13 = var_12 == 0 ? 0 : var_2 [ var_12 - 1 ] ;
      int var_14 = var_12 == var_0 . length - 1 ? 0 : var_3 [ var_12 + 1 ] ;
      max = Math . max ( max , var_13 + var_14 + 1 ) ;
    }
  }
  return max ;
}
