DP solution to minPathSum