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.
understanding your code needs deeper C(++) knowledge, things with pointers (*) and -> ...
1) the charming thing on recursive solution is because of it's simple syntax
2) recursion is a little shorter
3) with your solution you are shifting the tail towards the head AND change pointers, in recursion the result node stays from beginning to end, just changing pointers
.... only to mention some ... :)
(some sarcasm: .... being able to be "copied" into nearly every other language and then all the people here are telling proud: "i solved this challenge") ... can't stop rolling on the floor because of laughing :)
Reverse a linked list
You are viewing a single comment's thread. Return to all comments →
understanding your code needs deeper C(++) knowledge, things with pointers (*) and -> ... 1) the charming thing on recursive solution is because of it's simple syntax 2) recursion is a little shorter 3) with your solution you are shifting the tail towards the head AND change pointers, in recursion the result node stays from beginning to end, just changing pointers
.... only to mention some ... :)
(some sarcasm: .... being able to be "copied" into nearly every other language and then all the people here are telling proud: "i solved this challenge") ... can't stop rolling on the floor because of laughing :)