666苗大顺 发表于 2022-11-10 22:43

反转链表代码

class Solution {
    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;
    }
}

清心如水 发表于 2022-11-11 07:53

闪耀的空白 发表于 2022-11-11 08:14

power3 发表于 2022-11-11 08:23

hzbaige 发表于 2022-11-11 08:30

谢谢分享

leslie_aqiang 发表于 2022-11-11 08:53

techlink81 发表于 2022-11-11 08:55

captain漠九 发表于 2022-11-11 08:55

huangchang 发表于 2022-11-11 08:56

lqsgg 发表于 2022-11-11 08:58

页: [1] 2
查看完整版本: 反转链表代码