Skip to content

Commit 2d7a39d

Browse files
committed
Create README - LeetHub
1 parent 024197e commit 2d7a39d

File tree

1 file changed

+40
-0
lines changed
  • 0714-best-time-to-buy-and-sell-stock-with-transaction-fee

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<h2><a href="https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee">714. Best Time to Buy and Sell Stock with Transaction Fee</a></h2><h3>Medium</h3><hr><p>You are given an array <code>prices</code> where <code>prices[i]</code> is the price of a given stock on the <code>i<sup>th</sup></code> day, and an integer <code>fee</code> representing a transaction fee.</p>
2+
3+
<p>Find the maximum profit you can achieve. You may complete as many transactions as you like, but you need to pay the transaction fee for each transaction.</p>
4+
5+
<p><strong>Note:</strong></p>
6+
7+
<ul>
8+
<li>You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).</li>
9+
<li>The transaction fee is only charged once for each stock purchase and sale.</li>
10+
</ul>
11+
12+
<p>&nbsp;</p>
13+
<p><strong class="example">Example 1:</strong></p>
14+
15+
<pre>
16+
<strong>Input:</strong> prices = [1,3,2,8,4,9], fee = 2
17+
<strong>Output:</strong> 8
18+
<strong>Explanation:</strong> The maximum profit can be achieved by:
19+
- Buying at prices[0] = 1
20+
- Selling at prices[3] = 8
21+
- Buying at prices[4] = 4
22+
- Selling at prices[5] = 9
23+
The total profit is ((8 - 1) - 2) + ((9 - 4) - 2) = 8.
24+
</pre>
25+
26+
<p><strong class="example">Example 2:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong> prices = [1,3,7,5,10,3], fee = 3
30+
<strong>Output:</strong> 6
31+
</pre>
32+
33+
<p>&nbsp;</p>
34+
<p><strong>Constraints:</strong></p>
35+
36+
<ul>
37+
<li><code>1 &lt;= prices.length &lt;= 5 * 10<sup>4</sup></code></li>
38+
<li><code>1 &lt;= prices[i] &lt; 5 * 10<sup>4</sup></code></li>
39+
<li><code>0 &lt;= fee &lt; 5 * 10<sup>4</sup></code></li>
40+
</ul>

0 commit comments

Comments
 (0)