题解 | #反转链表#
package main import . "nc_tools" /* * type ListNode struct{ * Val int * Next *ListNode * } */ /** * * @param pHead ListNode类 * @return ListNode类 */ func ReverseList(head *ListNode ) *ListNode { if head == nil || head.Next == nil { return head } newHead := ReverseList(head.Next) head.Next.Next = head head.Next = nil return newHead }