package leetcode;

/**
 * https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/
 */
public class Problem714 {
    public int maxProfit(int[] prices, int fee) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem714 prob = new Problem714();
        System.out.println(prob.maxProfit(new int[]{1, 3, 2, 8, 4, 9}, 2)); // 8
        System.out.println(prob.maxProfit(new int[]{1, 3, 2, 6, 8, 4, 9}, 2)); // 8
        System.out.println(prob.maxProfit(new int[]{1, 4, 2, 1, 4, 8, 4, 9}, 2)); // 9
    }
}

@@ -195,38 +195,26 @@
     
-// TODO%0A        return
+int cash =
  0;%0A    
 %7D%0A%0A 
@@ -213,351 +213,227 @@
     
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem714 prob = new Problem714();%0A        System.out.println(prob.maxProfit(new int%5B%5D%7B1, 3, 2, 8, 4, 9%7D, 2)); // 8%0A        System.out.println(prob.maxProfit(new int%5B%5D%7B1, 3, 2, 6, 8, 4, 9%7D, 2)); // 8%0A        System.out.println(prob.maxProfit(new int%5B%5D%7B1, 4, 2, 1, 4, 8, 4, 9%7D, 2)); // 9
+int hold = -prices%5B0%5D;%0A        for (int i = 1; i %3C prices.length; i++) %7B%0A            cash = Math.max(cash, hold + prices%5Bi%5D - fee);%0A            hold = Math.max(hold, cash - prices%5Bi%5D);%0A        %7D%0A        return cash;
 %0A   

Solve problem 714 (not really)