rewrite leetcode minmum path sum