leetcode - Reverse Linked List @ Sat, Feb 18, 2023 9:53 PM
leetcode - Reverse Linked List @ Sun, Feb 19, 2023 9:27 AM
Expand 26 lines ...
27
*/
28
29
function reverseList(head: ListNode | null): ListNode | null {
30
+
// base case, breaking recursive loop
if (head === null || head.next === null) return head;
31
const newHead = reverseList(head.next);
32
head.next.next = head;
33
Expand 33 lines ...