added solution to the DP problem of calculating the min cost path