Adding hash lookup table for these 2 solutions will avoid duplicate calculations, turning them into dynamic programming examples. After all, in many cases DP is just an optimization on top of recursion.
Adding hash lookup table for these 2 solutions will avoid duplicate calculations, turning them into dynamic programming examples. After all, in many cases DP is just an optimization on top of recursion.