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