<awangdev>122. Best Time to Buy and Sell Stock II_3.java
public int maxProfit(int[] prices) {
        if (prices == null || prices.length == 0) return 0;
        int n = prices.length;
        int[][] dp = new int[n+1][2];
        dp[0][0] = dp[0][1] = 0;
        dp[1][0] = - prices[0];
        
        for (int i = 2; i <= n; i++) {
            dp[i][0] = Math.max(dp[i-1][0], dp[i-1][1] - prices[i-1]); 
            dp[i][1] = Math.max(dp[i-1][1], dp[i-1][0] + prices[i-1]);
        }
        return dp[n][1];
    }
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_7 = new int [ var_4 + 1 ] [ 2 ] ;
  var_7 [ 0 ] [ 0 ] = var_7 [ 0 ] [ 1 ] = 0 ;
  var_7 [ 1 ] [ 0 ] = - var_0 [ 0 ] ;
  for ( int var_8 = 2 ;
  var_8 <= var_4 ;
  var_8 ++ ) {
    var_7 [ var_8 ] [ 0 ] = Math . max ( var_7 [ var_8 - 1 ] [ 0 ] , var_7 [ var_8 - 1 ] [ 1 ] - var_0 [ var_8 - 1 ] ) ;
    var_7 [ var_8 ] [ 1 ] = Math . max ( var_7 [ var_8 - 1 ] [ 1 ] , var_7 [ var_8 - 1 ] [ 0 ] + var_0 [ var_8 - 1 ] ) ;
  }
  return var_7 [ var_4 ] [ 1 ] ;
}
