Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

triangle minimum path sum c#

public class Solution 
{
    public int MinimumTotal(IList<IList<int>> t) 
    {
        for(var i=t.Count-2; i>=0; i-- )
        {
            for(var j=0;j<t[i].Count;j++)
            {
                t[i][j] = Math.Min(t[i][j]+t[i+1][j],t[i][j]+t[i+1][j+1]);
            }
        }
        return t[0][0];
    }
}
Source by leetcode.com #
 
PREVIOUS NEXT
Tagged: #triangle #minimum #path #sum
ADD COMMENT
Topic
Name
8+6 =