Compass interview question

Dynammic Programming