输入一个链表,反转链表后,输出新链表的表头。
/*function ListNode(x){
this.val = x;
this.next = null;
}*/
function ReverseList(pHead)
{
if(pHead == null) return null;
var p1 = null,
temp = null;
while(pHead){
temp = pHead.next;
pHead.next = p1;
p1 = pHead;
pHead = temp;
}
return p1
}