剑指offer T8跳台阶

 由推导可知,递推公式为 f(n) = f(n-1) + f(n-2)

迭代法:

 递归:

 递归优化(保存结果,剪枝):

 

原文地址:https://www.cnblogs.com/jiguang321/p/11619071.html