题解 | #反转链表#
反转链表
https://www.nowcoder.com/practice/75e878df47f24fdc9dc3e400ec6058ca
/*function ListNode(x){
this.val = x;
this.next = null;
}*/
function ReverseList(pHead)
{
// write code here
let pre = null;
let cur = pHead;
while(cur){
let next = cur.next;
cur.next = pre;
pre = cur;
cur = next;
}
return pre;
}
module.exports = {
ReverseList : ReverseList
};
#华为机试,emo了#