<gouthampradhan>dynamic_programming_BestTimeToBuyAndSellStockIII_1.java
public int maxProfit(int[] prices) {
    if (prices.length == 0 || prices.length == 1) return 0;
    int[] dp = new int[prices.length];
    int min = prices[0];
    int max = prices[prices.length - 1];
    for (int i = prices.length - 2; i >= 0; i--) {
      dp[i] = Math.max(max - prices[i], dp[i + 1]);
      max = Math.max(max, prices[i]);
    }
    max = Integer.MIN_VALUE;
    for (int i = 0; i < prices.length; i++) {
      max = Math.max(max, prices[i] - min + dp[i]);
      min = Math.min(min, prices[i]);
    }
    return max;
  }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 . length == 0 || var_0 . length == 1 ) return 0 ;
  int [ ] var_4 = new int [ var_0 . length ] ;
  int min = var_0 [ 0 ] ;
  int max = var_0 [ var_0 . length - 1 ] ;
  for ( int var_8 = var_0 . length - 2 ;
  var_8 >= 0 ;
  var_8 -- ) {
    var_4 [ var_8 ] = Math . max ( max - var_0 [ var_8 ] , var_4 [ var_8 + 1 ] ) ;
    max = Math . max ( max , var_0 [ var_8 ] ) ;
  }
  max = Integer . MIN_VALUE ;
  for ( int var_8 = 0 ;
  var_8 < var_0 . length ;
  var_8 ++ ) {
    max = Math . max ( max , var_0 [ var_8 ] - min + var_4 [ var_8 ] ) ;
    min = Math . min ( min , var_0 [ var_8 ] ) ;
  }
  return max ;
}
