Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best time to buy and sell stock II #168

Open
YashviMehta03 opened this issue Oct 9, 2024 · 0 comments
Open

Best time to buy and sell stock II #168

YashviMehta03 opened this issue Oct 9, 2024 · 0 comments

Comments

@YashviMehta03
Copy link
Contributor

Problem statement -
You are given an integer array prices where prices[i] is the price of a given stock on the ith day.
On each day, you may decide to buy and/or sell the stock. You can only hold at most one share of the stock at any time. However, you can buy it then immediately sell it on the same day.
Find and return the maximum profit you can achieve.

My approach would be using dynamic programming to solve it. I will implement a bottom-up approach that would calculate maximum profit iteratively while handling all edge cases.

I look forward to contributing for solving this problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant