4 ms·
In an interview setting, I'm sure you could hack something together and then improve it! Eg. an iterative Fibonacci is easy to reason about if you're not used t
by bcherny 9y ago
In an interview setting, I'm sure you could hack something together and then improve it! Eg. an iterative Fibonacci is easy to reason about if you're not used to recursion.
It's a good question for junior people because there's so many ways to write it: iterative, recursive, recursive + memoized, eagerly streamed, lazily streamed.
That said, it is not a problem you'll have in the real world, so at best it's good to get a feel for how a candidate thinks through problems, how easily they can reframe an algorithm in different ways, and how they can reason about tradeoffs of different approaches.