Meta interview question

Fibonacci: recursive and iterative.

Interview Answers

Anonymous

15 Aug 2014

// Iterative public static long getFibIterative(int n){ int prev1 = 1; int prev2 = 1; // it's like 1 1 2 3 5 8 // prev1, prev2, 2 3 5 8 // let i be the index for(int i=2; i

6

Anonymous

15 Aug 2014

// Recursive public static long getFib(int n){ if (n <=1) return n; return getFib(n-1) + getFib(n-2); }

3

Anonymous

26 Feb 2021

It's essential to demonstrate that you can really go deep... there are plenty of followup questions and (sometimes tangential) angles to explore. There's a lot of Software Engineer Intern experts who've worked at Facebook, who provide this sort of practice through mock interviews. There's a whole list of them curated on Prepfully. prepfully.com/practice-interviews