Mrinalini Bansal
Thank you for explanation, this is a beautiful solution.
I've been studied for this solution for 2 days and finally get the idea.
However, I still don't know how to get to this solution from observing optimal substructure.
I don't know what is the optimal substructure and also how to get to the recursive function from optimal substructure?
Tong Nong Lin
Hi, regarding to problem IV, you mentioned
approach 2
For every stock, calculate cash in hand after buying and selling it in the two arrays. This is done in a loop j from 1 till k where j denotes the cash in hand after jth buy and sell.
so j is from 1 to k
but in code, j is from k to 1?
btw, your linkedln is locked and can't send message