here is my code: https://ideone.com/rRMoGs
Also getting a TLE. why?
Getting WA in Stock Selling
Hey @pragyanvarshney
Your approach is unfortunately incorrect. Please have a look at this https://www.geeksforgeeks.org/maximum-profit-by-buying-and-selling-a-share-at-most-k-times/
My approach is simply to generate all transactions possible then select the largest k transactions. Where am I wrong?
@pragyanvarshney
A transaction can start only after a previous transaction ends. They cant overlap. It is a DP question. You’re solving it using a greedy approach.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.