206. Reverse Linked List #
题目 #
Reverse a singly linked list.
题目大意 #
翻转单链表
解题思路 #
按照题意做即可。
代码 #
package leetcode
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
// ListNode define
type ListNode struct {
Val int
Next *ListNode
}
func reverseList(head *ListNode) *ListNode {
var behind *ListNode
for head != nil {
next := head.Next
head.Next = behind
behind = head
head = next
}
return behind
}