单链表反转

Posted by KANG's BLOG on Tuesday, March 1, 2022
public ListNode reverseList (ListNode head) {
  ListNode first = null;
  ListNode current = head;
  ListNode next = null;
  while (current != null) {
    next = current.next;
    current.next = first;
    first = current;
    current = next;
  }
  return first;
}