It is marked as Recursion on HR, but the optimal solution is DP.
Step by step, discover internal mechanism.