My Blog List

[Leetcode Solution] Triangle

Analysis

  • Classical Dynamic Programming problem
  • Let f[i][j] denote the minimum path sum from top to node(i,j), f[i][j]=min(f[i-1][j-1],f[i-1][j])+v[i][j]
  • In practical can use two vector iterative store the current and next level states rather then store all the f[i][j]

Note

Code