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?