Dynamic Programming - Task 2