You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -15,16 +19,44 @@ public ListNode reverseList(ListNode head) {
15
19
}
16
20
returnnewHead;
17
21
}
22
+
23
+
//following the above iterative version, the recursive solution flows out so naturally, basically, we just replaced the while loop with a recursive function
24
+
//still, a null newHead proves to be very helpful.
//the above recursive function could of course be shortened to below, but the above one is just more intuitive and easier to follow and sort out your logic
0 commit comments