title: How do I convert this recursion to dp
body: <p>I am trying to solve <a href="https://leetcode.com/problems/triangle" rel="nofollow noreferrer">this</a> problem. I believe my solution does work, but it takes more time. This is my solution - at each step, I calculate the minimum sum if I choose i or i+1 index.</p>
  <pre><code>class Solution 
  {
      public int minimumTotal(List&lt;List&lt;Integer&gt;&gt; triangle) 
      {
          return minSum( triangle, 0, 0 );
      }
          
      public int minSum( List&lt;List&lt;Integer&gt;&gt; triangle, int row, int index )
      {
             if( row &gt;= triangle.size() )
                 return 0;
  
              int valueAtThisRow = triangle.get(row).get(index);
  
              return Math.min( valueAtThisRow + minSum(triangle, row+1, index), 
                               valueAtThisRow + minSum(triangle, row+1, index+1));
      }
  }
  </code></pre>
  <p>I think more appropriate way is to use DP. Please share any suggestions on how I can convert this to a DP.</p>