Vidiemme interview question

Dinamic programming, working on intervals