We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9e8957b commit cfd7b05Copy full SHA for cfd7b05
src/main/java/com/fishercoder/solutions/_714.java
@@ -40,8 +40,8 @@ public int maxProfit(int[] prices, int fee) {
40
int cash = 0;
41
int hold = -prices[0];
42
for (int i = 1; i < prices.length; i++) {
43
- cash = Math.max(cash, hold + prices[i] - fee);
44
- hold = Math.max(hold, cash - prices[i]);
+ cash = Math.max(cash, hold + prices[i] - fee);//this means to sell the stock: gain the current ith day's price and pay the transaction fee
+ hold = Math.max(hold, cash - prices[i]);//this means to buy in this stock on the ith day's price.
45
}
46
return cash;
47
0 commit comments