<awangdev>121. Best Time to Buy and Sell Stock_4.java
public int maxProfit(int[] prices) {
        if (prices == null || prices.length == 0) {
            return 0;
        }
        int n = prices.length;
        int[] dp = new int[2];
        dp[0] = Integer.MAX_VALUE;
        int profit = 0;
        for (int i = 1; i <= n; i++) {
            dp[i % 2] = Math.min(dp[(i - 1) % 2], prices[i - 1]);
            profit = Math.max(profit, prices[i - 1] - dp[i % 2]);
        }
        return profit;
    }
public int sample_funcname ( int [ ] var_0 ) {
  if ( var_0 == null || var_0 . length == 0 ) {
    return 0 ;
  }
  int var_4 = var_0 . length ;
  int [ ] var_6 = new int [ 2 ] ;
  var_6 [ 0 ] = Integer . MAX_VALUE ;
  int var_9 = 0 ;
  for ( int var_11 = 1 ;
  var_11 <= var_4 ;
  var_11 ++ ) {
    var_6 [ var_11 % 2 ] = Math . min ( var_6 [ ( var_11 - 1 ) % 2 ] , var_0 [ var_11 - 1 ] ) ;
    var_9 = Math . max ( var_9 , var_0 [ var_11 - 1 ] - var_6 [ var_11 % 2 ] ) ;
  }
  return var_9 ;
}
