Pergunta de entrevista da empresa Salesforce

Can you write an algorithm that computes the nth Fibonacci number in linear time or faster?

Resposta da entrevista

Sigiloso

14 de fev. de 2017

//Computes nth fibonacci number in linear time O(n) public static int fibonacci(int n){ int f0=0, f1=1, f2=0; for(int i=2; i