isospeedrix
Highest Rated Comments
isospeedrix2 karma
Good to know. I was a junior back then but now if someone said recursion is superior id dispute that point lol. Thanks
isospeedrix1 karma
Oh true that’s good to know too.
In that case what’s the best loop way without huge array? Well I suppose i could just overwrite/remove the unneeded numbers in the previous part of the sequence
isospeedrix3 karma
10 years ago I got consistently asked in interviews Write a function that returns the nth number of Fibonacci sequence.
I always answered using a loop and array and filling in the array with the sum of the previous two values. However every interviewer told me “is there a better way?” And implied that they wanted the answer using recursion. Back when I didn’t know the recursion answer I failed those interviews but I went to study that method later so I know it now. Its a lot less intuitive. But still…
Is recursion really superior to the loop array method?
View HistoryShare Link