<gouthampradhan>dynamic_programming_BestTimeToBuyAndSellStocks_1.java
public int maxProfit(int[] prices) {
    if (prices.length == 0) return 0;
    int[] max = new int[prices.length];
    max[prices.length - 1] = prices[prices.length - 1];
    for (int i = prices.length - 2; i >= 0; i--) {
      max[i] = Math.max(prices[i], max[i + 1]);
    }
    int result = Integer.MIN_VALUE;
    for (int i = 0, l = max.length; i < l; i++) {
      result = Math.max(result, max[i] - prices[i]);
    }
    return result;
  }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 . length == 0 ) return 0 ;
  int [ ] max = new int [ var_0 . length ] ;
  max [ var_0 . length - 1 ] = var_0 [ var_0 . length - 1 ] ;
  for ( int var_6 = var_0 . length - 2 ;
  var_6 >= 0 ;
  var_6 -- ) {
    max [ var_6 ] = Math . max ( var_0 [ var_6 ] , max [ var_6 + 1 ] ) ;
  }
  int var_10 = Integer . MIN_VALUE ;
  for ( int var_6 = 0 , var_11 = max . length ;
  var_6 < var_11 ;
  var_6 ++ ) {
    var_10 = Math . max ( var_10 , max [ var_6 ] - var_0 [ var_6 ] ) ;
  }
  return var_10 ;
}
