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

/**
 * 
 * @param pHead ListNode类 
 * @return ListNode类
*/
func ReverseList( pHead *ListNode ) *ListNode {
    // write code here
    if pHead==nil || pHead.Next==nil{
        return pHead
    }

    var newHead *ListNode
    for pHead!=nil{
        pNext:=pHead.Next
        pHead.Next=newHead
        newHead=pHead
        pHead=pNext
    }
    return newHead
}