Blue Ocean: minimum path sum of a number triangle
minimum path sum of a number triangle The key observation here is that viewing this triangle as a tree, for any given subtree, the minimum path sum is the minimum of all of its subtrees plus the number at the root. At the leaf level, the minimum path sum is the value at the leaves. If we use dynamic programming, keep track of the minimum path sum at lower level, and then going up to calculate the min path sum at higher level. public static int minPath(ListRead full article from Blue Ocean: minimum path sum of a number triangle
No comments:
Post a Comment