Bentley Systems interview question

Dynamic Programming Algorithm coding question