206. 反转链表
反转一个单链表。
示例:
输入: 1->2->3->4->5->NULL
输出: 5->4->3->2->1->NULL
Code
/*** Definition for singly-linked list.* type ListNode struct {* Val int* Next *ListNode* }*/
func reverseList(head *ListNode) *ListNode {x := heady := headvar z *ListNodetemp := headfor head != nil {x = tempy = temp.Nextx.Next = zif y == nil {break}temp = yz = x}return x
}