Fivestars Interview Question

Any improvement on Fibonacci .

Interview Answers

Anonymous

Mar 7, 2014

I'm assuming this means: return an improvement of the terrible recursive version. here it is in python: def fib(n): n -=1 #for the user who calls it assuming 1-indexing i, a, b = 0, 0, 1 while i < n: a, b = b, a+b i+=1 return a

Anonymous

Dec 8, 2016

The interviewer was looking for the memoization of fibonacci. You can still answer this one recursively in O(n) time complexity and O(n) space complexity. It seems this company likes problems from cracking the coding interview