ReverseLinkedList

12345
54321
12345
function reverseLinkedList (head: ListNode | null): ListNode | null {
  if (!head) return null;
  
  let curr: ListNode | null  = head;
  let next: ListNode | null = curr.next;
  let prev: ListNode | null = null;
  
  while (curr) {
      next = curr.next;
      curr.next = prev;
      
      prev = curr;
      curr = next;
  }

  return prev;
};