<awangdev>Trapping Rain Water II_3.java
public int trapRainWater(int[][] heightMap) {
        if (heightMap == null || heightMap.length == 0 || heightMap[0] == null || heightMap[0].length == 0) {
            return 0;
        }
        int m = heightMap.length;
        int n = heightMap[0].length;
        int[][] maxLeft = new int[m][n];
        int[][] maxRight = new int[m][n];
        int[][] maxUp = new int[m][n];
        int[][] maxDown = new int[m][n];
        
        for (int i = 0; i < m; i++) {
            maxLeft[i][0] = heightMap[i][0];
            maxRight[i][n - 1] = heightMap[i][n - 1];
        }
        for (int j = 0; j < n; j++) {
            maxUp[0][j] = heightMap[0][j];
            maxDown[m - 1][j] = heightMap[m - 1][j];
        }
        for (int i = 0; i < m; i++) {
            for (int j = 1; j < n; j++) {
                maxLeft[i][j] = Math.max(maxLeft[i][j - 1], heightMap[i][j]);
                maxRight[i][n - j - 1] = Math.max(maxRight[i][n - j], heightMap[i][n - j - 1]);
            }
        }
        for (int j = 0; j < n; j++) {
            for (int i = 1; i < m; i++) {
                maxUp[i][j] = Math.max(maxUp[i - 1][j], heightMap[i][j]);
                maxDown[m - i - 1][j] = Math.max(maxDown[m - i][j], heightMap[m - i - 1][j]);
            }
        }
        
        int total = 0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int lowestHeight = Math.min(Math.min(maxLeft[i][j], maxRight[i][j]), Math.min(maxUp[i][j], maxDown[i][j]));
                total += lowestHeight > heightMap[i][j] ? lowestHeight - heightMap[i][j] : 0;
            }
        }
        return total;
    }
public int sample_funcname ( int [ ] [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 || var_0 [ 0 ] == null || var_0 [ 0 ] . length == 0 ) {
    return 0 ;
  }
  int var_4 = var_0 . length ;
  int var_5 = var_0 [ 0 ] . length ;
  int [ ] [ ] var_6 = new int [ var_4 ] [ var_5 ] ;
  int [ ] [ ] var_7 = new int [ var_4 ] [ var_5 ] ;
  int [ ] [ ] var_8 = new int [ var_4 ] [ var_5 ] ;
  int [ ] [ ] var_9 = new int [ var_4 ] [ var_5 ] ;
  for ( int var_10 = 0 ;
  var_10 < var_4 ;
  var_10 ++ ) {
    var_6 [ var_10 ] [ 0 ] = var_0 [ var_10 ] [ 0 ] ;
    var_7 [ var_10 ] [ var_5 - 1 ] = var_0 [ var_10 ] [ var_5 - 1 ] ;
  }
  for ( int var_12 = 0 ;
  var_12 < var_5 ;
  var_12 ++ ) {
    var_8 [ 0 ] [ var_12 ] = var_0 [ 0 ] [ var_12 ] ;
    var_9 [ var_4 - 1 ] [ var_12 ] = var_0 [ var_4 - 1 ] [ var_12 ] ;
  }
  for ( int var_10 = 0 ;
  var_10 < var_4 ;
  var_10 ++ ) {
    for ( int var_12 = 1 ;
    var_12 < var_5 ;
    var_12 ++ ) {
      var_6 [ var_10 ] [ var_12 ] = Math . max ( var_6 [ var_10 ] [ var_12 - 1 ] , var_0 [ var_10 ] [ var_12 ] ) ;
      var_7 [ var_10 ] [ var_5 - var_12 - 1 ] = Math . max ( var_7 [ var_10 ] [ var_5 - var_12 ] , var_0 [ var_10 ] [ var_5 - var_12 - 1 ] ) ;
    }
  }
  for ( int var_12 = 0 ;
  var_12 < var_5 ;
  var_12 ++ ) {
    for ( int var_10 = 1 ;
    var_10 < var_4 ;
    var_10 ++ ) {
      var_8 [ var_10 ] [ var_12 ] = Math . max ( var_8 [ var_10 - 1 ] [ var_12 ] , var_0 [ var_10 ] [ var_12 ] ) ;
      var_9 [ var_4 - var_10 - 1 ] [ var_12 ] = Math . max ( var_9 [ var_4 - var_10 ] [ var_12 ] , var_0 [ var_4 - var_10 - 1 ] [ var_12 ] ) ;
    }
  }
  int var_15 = 0 ;
  for ( int var_10 = 0 ;
  var_10 < var_4 ;
  var_10 ++ ) {
    for ( int var_12 = 0 ;
    var_12 < var_5 ;
    var_12 ++ ) {
      int var_17 = Math . min ( Math . min ( var_6 [ var_10 ] [ var_12 ] , var_7 [ var_10 ] [ var_12 ] ) , Math . min ( var_8 [ var_10 ] [ var_12 ] , var_9 [ var_10 ] [ var_12 ] ) ) ;
      var_15 += var_17 > var_0 [ var_10 ] [ var_12 ] ? var_17 - var_0 [ var_10 ] [ var_12 ] : 0 ;
    }
  }
  return var_15 ;
}
