Please consume this content on nados.pepcoding.com for a richer experience. It is necessary to solve the questions while watching videos, nados.pepcoding.com enables that.
NADOS also enables doubt support, career opportunities and contests besides free of charge content for learning. With this video, we explained the buy and sell stock questions of dynamic programming. In this video, we discuss the question where we are required to buy and sell stock with two transactions such that maximum profit is obtained from the transaction. In this problem,
1. You are given a number n, representing the number of days.
2. You are given n numbers, where ith number represents price of stock on ith day.
3. You are required to print the maximum profit you can make if you are allowed two transactions at-most.
Note - There can be no overlapping transaction. One transaction needs to be closed (a buy followed by a sell) before opening another transaction (another buy).
To attempt and submit this question, click here: https://www.pepcoding.com/resources/o...
For a better experience and more exercises, VISIT:
#dynamicprogramming #buysellstocks
Have a look at our result:
Follow us on our FB page: / pepcoding
Follow us on Instagram: / pepcoding
Follow us on LinkedIn: / pepcoding-education
Join us on Telegram: https://t.me/joinchat/UVTjJE83a-zFnPB
Watch video Best Time to Buy and Sell Stocks - Two Transaction Allowed (Hard) | Dynamic Programming online without registration, duration hours minute second in high quality. This video was added by user Pepcoding 08 August 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 55,013 once and liked it 1.7 thousand people.