We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The iterative solution is more efficient space and timewise. Recursion is very nice for us to read and understand, but has some overhead and takes stack space for every function call. Sure, for an exercise such as this or a small number of calls it is fine, but for some more heavyweight application it will cost more.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Reverse a linked list
You are viewing a single comment's thread. Return to all comments →
The iterative solution is more efficient space and timewise. Recursion is very nice for us to read and understand, but has some overhead and takes stack space for every function call. Sure, for an exercise such as this or a small number of calls it is fine, but for some more heavyweight application it will cost more.