The Wayback Machine - https://web.archive.org/web/20250519122032/https://github.com/TheAlgorithms/Java/issues/3470
Skip to content

DP on Stocks , Buy and sell stocks  #3470

Closed
@sanglap-02

Description

@sanglap-02

I have noticed that there are no problem on buy and sell stocks in the Dynamic program folder. I would love to contribute some problems on Dp on stocks
for Example :
problem statement :

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. You may complete at most two transactions.
Note: You may not engage in multiple transactions simultaneously (i.e., you must sell the stock before you buy again).

example
Input: prices = [3,3,5,0,0,3,1,4]
Output: 6
Explanation: Buy on day 4 (price = 0) and sell on day 6 (price = 3), profit = 3-0 = 3.
Then buy on day 7 (price = 1) and sell on day 8 (price = 4), profit = 4-1 = 3.

Please assign this to me. I would love to contribute this question

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions