diff --git a/OJ notes/pages/Leetcode Reverse-Linked-List.md b/OJ notes/pages/Leetcode Reverse-Linked-List.md index 4bd9d75..fca16b8 100644 --- a/OJ notes/pages/Leetcode Reverse-Linked-List.md +++ b/OJ notes/pages/Leetcode Reverse-Linked-List.md @@ -74,6 +74,7 @@ The in place insert is easier to understand, and simple to implement, using a ve > The recursion algorithm takes the advantage of the fact that when you change the node's next properties or nodes after that, the node before still points to the same node, so when every node after **tmp** is reversed, simply move **tmp** after **tmp->next**, which now points to the tail of reversed list > #### Why return the last element of the original list? > It returns the last element in the original list to make sure you are always returning the head of the reversed array, since for any reversed list, the last one comes first. +> **The only recursive part is returning the _tail node_.** ### Solution I've referred to this guy: https://leetcode.com/problems/reverse-linked-list/discuss/58130/C%2B%2B-Iterative-and-Recursive