Need help on reading and understanding the code on this problem.

This is not an easy problem and books can dedicate subchapters to it. What specific questions do you have about it?

Have you seen the Eric Demaine MIT lectures? (I think he touches on this one)

Not really any specific questions. I’ve been on the CS102 and they break down the code and it helps me understand the problem. So I would like the code be broken down.

Do you know the specific name of the lecture done by Eric? Is it on youtube?

To be fair, you might have to watch some lead-in lectures since the angles might be different from a straightforward approach. What I mean by this is they flesh out the mathematical and algorithmic motivation for the problem-structure and why it works, which is in general going to be better for internalizing the thing in the long haul. This linked video is old and they have new ones in dynamic programming from the last 2 years… the approaches are similar but different enough that they warrant watching both sets, in my opinion.