码迷,mamicode.com
首页 > 其他好文 > 详细

[CTCI] Fobonacci Problem

时间:2015-08-12 21:38:44      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

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}$

[CTCI] Fobonacci Problem

标签:

原文地址:http://www.cnblogs.com/deepblueme/p/4725425.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!