<awangdev>42. Trapping Rain Water_2.java
public int trap(int[] height) {
        if (height == null || height.length == 0) return 0;
        int n = height.length, left = 0, right = n - 1;
        int maxLeft = height[0], maxRight = height[n - 1];
        
        int total = 0;
        while (left < right) {
            if (maxLeft < maxRight) {
                left++;
                if (maxLeft > height[left]) total += maxLeft - height[left];
                else maxLeft = height[left]; 
            } else {
                right--;
                if (maxRight > height[right]) total += maxRight - height[right];
                else maxRight = height[right];
            }
        }
        return total;
    }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 ) return 0 ;
  int var_4 = var_0 . length , var_5 = 0 , var_7 = var_4 - 1 ;
  int var_8 = var_0 [ 0 ] , var_9 = var_0 [ var_4 - 1 ] ;
  int var_10 = 0 ;
  while ( var_5 < var_7 ) {
    if ( var_8 < var_9 ) {
      var_5 ++ ;
      if ( var_8 > var_0 [ var_5 ] ) var_10 += var_8 - var_0 [ var_5 ] ;
      else var_8 = var_0 [ var_5 ] ;
    }
    else {
      var_7 -- ;
      if ( var_9 > var_0 [ var_7 ] ) var_10 += var_9 - var_0 [ var_7 ] ;
      else var_9 = var_0 [ var_7 ] ;
    }
  }
  return var_10 ;
}
