Sam Gavis-Hughson
Aug 29, 2017 · 1 min read

This is a great question. It’s definitely not *necessary* to do the last step, since it shouldn’t change the performance, but in many problems it can make the code a lot simpler. In the case of the Fibonacci problem, it also gives you the opportunity to optimize the solution even further (although I didn’t include that in this post). I’d definitely recommend grabbing the ebook (www.byte-by-byte.com/dpbook) so that you can see other examples of problems and hopefully it’ll make more sense.

)
    Sam Gavis-Hughson

    Written by

    https://www.byte-by-byte.com coding interview prep