206. 反转链表 - 力扣(LeetCode) (leetcode-cn.com)
思路:
/** * Definition for singly-linked list. * type ListNode struct { * Val int * Next *ListNode * } */ func reverseList(head *ListNode) *ListNode { curHead:=head preHead:=new(ListNode) preHead=nil for curHead!=nil{ tempHead:=curHead.Next curHead.Next=preHead preHead=curHead curHead=tempHead } return preHead }