F_G

许多问题需要说清楚就可以&&走永远比跑来的重要

导航

[CTCI] Fobonacci Problem

The problem is well known, so there is no need to repeat it!

we can apply the iteration function f(n+1) = f(n)+f(n-1), however the time complexity is O(N).

We can reduce the time compexity to O(log(N)) using the method below.

f(1)=1,f(2)=1

$\begin{matrix}

f(n)&f(n-1)&\\

0& 0\\

\end{matrix}$

posted on 2015-08-12 20:04  F_G  阅读(151)  评论(0编辑  收藏  举报