📜  java反向链表-Java代码示例

📅  最后修改于: 2022-03-11 14:52:18.513000             🧑  作者: Mango

代码示例1
public ListNode reverseList(ListNode head) {
    ListNode prev = null;
    ListNode curr = head;

      while(curr != null){
          ListNode next = curr.next;
          curr.next = prev;
          prev = curr;
          curr = next;
      }
    return prev;
    }