* struct ListNode {
 *	int val;
 *	struct ListNode *next;
 * };
 *
 * C语言声明定义全局变量请加上static,防止重复定义
 */

/**
 * 
 * @param pHead ListNode类 
 * @return ListNode类
 */


struct ListNode* ReverseList(struct ListNode* pHead ) {
    // write code here
    if((pHead->next == NULL) | (pHead == NULL))
    {
        return pHead;
    }
    struct ListNode* prenode;
    struct ListNode* nextnode;
    prenode = NULL;
    nextnode = NULL;
    while(pHead)
    {
        nextnode = pHead->next;
        pHead->next = prenode;
        prenode = pHead;
        pHead = nextnode; 
    }
    return prenode;
}