diff --git a/notes/24. 反转链表.md b/notes/24. 反转链表.md index 05bc439f..7db8fc88 100644 --- a/notes/24. 反转链表.md +++ b/notes/24. 反转链表.md @@ -1,18 +1,18 @@ # 24. 反转链表 -[NowCoder](https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca?tpId=13&tqId=11168&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github) +[Leetcode](https://leetcode.cn/problems/fan-zhuan-lian-biao-lcof/) ## 解题思路 ### 递归 ```java -public ListNode ReverseList(ListNode head) { +public ListNode trainningPlan(ListNode head) { if (head == null || head.next == null) return head; ListNode next = head.next; head.next = null; - ListNode newHead = ReverseList(next); + ListNode newHead = trainningPlan(next); next.next = head; return newHead; } @@ -23,7 +23,7 @@ public ListNode ReverseList(ListNode head) { 使用头插法。 ```java -public ListNode ReverseList(ListNode head) { +public ListNode trainningPlan(ListNode head) { ListNode newList = new ListNode(-1); while (head != null) { ListNode next = head.next;