Skip to content

Commit cfd7b05

Browse files
refactor 714
1 parent 9e8957b commit cfd7b05

File tree

1 file changed

+2
-2
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+2
-2
lines changed

src/main/java/com/fishercoder/solutions/_714.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public int maxProfit(int[] prices, int fee) {
4040
int cash = 0;
4141
int hold = -prices[0];
4242
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]);
43+
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
44+
hold = Math.max(hold, cash - prices[i]);//this means to buy in this stock on the ith day's price.
4545
}
4646
return cash;
4747
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy