
Best Time to Buy and Sell Stock - LeetCode
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction.
Best Time to Buy and Sell Stock II - LeetCode
You can only hold at most one share of the stock at any time. However, you can sell and buy the stock multiple times on the same day, ensuring you never hold more than one share of the stock.
Best Time to Buy and Sell Stock IV - LeetCode
Find the maximum profit you can achieve. You may complete at most k transactions: i.e. you may buy at most k times and sell at most k times. Note: You may not engage in multiple transactions …
Best Time to Buy and Sell Stock with Cooldown - LeetCode
Best Time to Buy and Sell Stock with Cooldown - You are given an array prices where prices [i] is the price of a given stock on the ith day. Find the maximum profit you can achieve.
Best Time to Buy and Sell Stock with Transaction Fee - LeetCode
At the end, the only legal states are that you don't own a share of stock, or that you do. Calculate the most profit you could have under each of these two cases.
3573. Best Time to Buy and Sell Stock V - LeetCode
* A short selling transaction: sell the stock on day 3 for $19 then buy back on day 4 for $8. * A normal transaction: buy the stock on day 5 for $1 then sell it on day 6 for $19.
Best Time to Buy and Sell Stock III - LeetCode
Note that you cannot buy on day 1, buy on day 2 and sell them later, as you are engaging multiple transactions at the same time. You must sell before buying again.
Best Time to Buy and Sell Stock using Strategy - LeetCode
Set the first k / 2 elements to 0 (hold). Set the last k / 2 elements to 1 (sell). The profit is defined as the sum of strategy[i] * prices[i] across all days. Return the maximum possible profit you can achieve. …
25 DP Problems To Revise Before Interviews - LeetCode
Nov 21, 2025 · 22. Best Time to Buy and Sell Stock IV - LeetCode 188 Pattern: K transactions (generalizes all stocks) Why: Master this, master all stock problems 23. Unique Paths II - LeetCode …
Capital Gain/Loss - LeetCode
Write a solution to report the Capital gain/loss for each stock. The Capital gain/loss of a stock is the total gain or loss after buying and selling the stock one or many times. Return the result table in any order. …