<awangdev>122. Best Time to Buy and Sell Stock II_5.java
public int maxProfit(int[] prices) {
        if (prices == null || prices.length <= 1) {
            return 0;
        }
        int[] buyOn = new int[prices.length];
        int[] sellOn = new int[prices.length];
        int length = prices.length;
        buyOn[length - 1] = 0;
        sellOn[length - 1] = prices[length - 1];
        for (int i = length - 2; i >= 0; i--) {
            buyOn[i] = Math.max(buyOn[i + 1], sellOn[i + 1] - prices[i]); 
            sellOn[i] = Math.max(sellOn[i + 1], buyOn[i + 1] + prices[i]);
        }
        return Math.max(0, buyOn[0]);
    }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length <= 1 ) {
    return 0 ;
  }
  int [ ] var_5 = new int [ var_0 . length ] ;
  int [ ] var_6 = new int [ var_0 . length ] ;
  int length = var_0 . length ;
  var_5 [ length - 1 ] = 0 ;
  var_6 [ length - 1 ] = var_0 [ length - 1 ] ;
  for ( int var_8 = length - 2 ;
  var_8 >= 0 ;
  var_8 -- ) {
    var_5 [ var_8 ] = Math . max ( var_5 [ var_8 + 1 ] , var_6 [ var_8 + 1 ] - var_0 [ var_8 ] ) ;
    var_6 [ var_8 ] = Math . max ( var_6 [ var_8 + 1 ] , var_5 [ var_8 + 1 ] + var_0 [ var_8 ] ) ;
  }
  return Math . max ( 0 , var_5 [ 0 ] ) ;
}
