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.
Dont all of this recursive calls blow up the stack? Seems like in-place iteration is the way to go here. Also, might as well use a regular stack for storing the pointers, seems less confusing to me.
EDIT: I tried it out, and even a list with only 5000 elements already throws a stack overflow. So this solution might work, but is really not usefull at all.
(Tested it on windows, I believe the stack size is around 1MB)
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 →
Dont all of this recursive calls blow up the stack? Seems like in-place iteration is the way to go here. Also, might as well use a regular stack for storing the pointers, seems less confusing to me.
EDIT: I tried it out, and even a list with only 5000 elements already throws a stack overflow. So this solution might work, but is really not usefull at all. (Tested it on windows, I believe the stack size is around 1MB)