<gouthampradhan>dynamic_programming_PaintHouseII_1.java
public int minCostII(int[][] costs) {
    if (costs.length == 0) return 0;
    int[][] lMin = new int[costs.length][costs[0].length];
    int[][] rMin = new int[costs.length][costs[0].length];
    for (int i = costs.length - 2; i >= 0; i--) {
      int min = Integer.MAX_VALUE;
      for (int j = 0; j < costs[0].length; j++) {
        lMin[i + 1][j] = min;
        min = Math.min(min, costs[i + 1][j]);
      }
      min = Integer.MAX_VALUE;
      for (int j = costs[0].length - 1; j >= 0; j--) {
        rMin[i + 1][j] = min;
        min = Math.min(min, costs[i + 1][j]);
      }
      for (int j = 0; j < costs[0].length; j++) {
        if (j == 0) {
          costs[i][j] = costs[i][j] + rMin[i + 1][j];
        } else if (j == costs[0].length - 1) {
          costs[i][j] = costs[i][j] + lMin[i + 1][j];
        } else {
          costs[i][j] = costs[i][j] + Math.min(lMin[i + 1][j], rMin[i + 1][j]);
        }
      }
    }
    int min = Integer.MAX_VALUE;
    for (int i = 0; i < costs[0].length; i++) {
      min = Math.min(min, costs[0][i]);
    }
    return min;
  }
public int sample_funcname ( int [ ] [ ] var_0 ) {
  if ( var_0 . length == 0 ) return 0 ;
  int [ ] [ ] var_3 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ;
  int [ ] [ ] var_4 = new int [ var_0 . length ] [ var_0 [ 0 ] . length ] ;
  for ( int var_6 = var_0 . length - 2 ;
  var_6 >= 0 ;
  var_6 -- ) {
    int min = Integer . MAX_VALUE ;
    for ( int var_10 = 0 ;
    var_10 < var_0 [ 0 ] . length ;
    var_10 ++ ) {
      var_3 [ var_6 + 1 ] [ var_10 ] = min ;
      min = Math . min ( min , var_0 [ var_6 + 1 ] [ var_10 ] ) ;
    }
    min = Integer . MAX_VALUE ;
    for ( int var_10 = var_0 [ 0 ] . length - 1 ;
    var_10 >= 0 ;
    var_10 -- ) {
      var_4 [ var_6 + 1 ] [ var_10 ] = min ;
      min = Math . min ( min , var_0 [ var_6 + 1 ] [ var_10 ] ) ;
    }
    for ( int var_10 = 0 ;
    var_10 < var_0 [ 0 ] . length ;
    var_10 ++ ) {
      if ( var_10 == 0 ) {
        var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + var_4 [ var_6 + 1 ] [ var_10 ] ;
      }
      else if ( var_10 == var_0 [ 0 ] . length - 1 ) {
        var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + var_3 [ var_6 + 1 ] [ var_10 ] ;
      }
      else {
        var_0 [ var_6 ] [ var_10 ] = var_0 [ var_6 ] [ var_10 ] + Math . min ( var_3 [ var_6 + 1 ] [ var_10 ] , var_4 [ var_6 + 1 ] [ var_10 ] ) ;
      }
    }
  }
  int min = Integer . MAX_VALUE ;
  for ( int var_6 = 0 ;
  var_6 < var_0 [ 0 ] . length ;
  var_6 ++ ) {
    min = Math . min ( min , var_0 [ 0 ] [ var_6 ] ) ;
  }
  return min ;
}
