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