• + 0 comments

    Your solution is a DP solution.

    You are calculating tn by solving the problem from t1 to tn, and recording the results in order to calculate the one you need.

    That's the whole idea of dynamic programming: to solve a complex instance of a problem using the solution to smaller instances.

    This problem is so simple that you can't really appreciate the technique. If you want an example of a more "serious" DP algorithm, you might look to a classic like the Wagner–Fischer algorithm to compute the distance between strings. It's simple enough but not trivial.