package main
import . "nc_tools"
/*
 * type ListNode struct{
 *   Val int
 *   Next *ListNode
 * }
 */

/**
 * 
 * @param pHead ListNode类 
 * @return ListNode类
*/
func ReverseList( pHead *ListNode ) *ListNode {
    if pHead == nil {
        return nil
    }

    VirtualRoot := &ListNode{Val: 0}
    VirtualRoot.Next = pHead
    start := VirtualRoot.Next
    next  := start.Next
    for next != nil {
        start.Next = next.Next
        next.Next = VirtualRoot.Next
        VirtualRoot.Next = next
        next = start.Next
    }

    return VirtualRoot.Next
    // write code here
}