BM1 反转链表
/*function ListNode(x){ this.val = x; this.next = null; }*/ function ReverseList(pHead) { // write code here if(!pHead) return pHead if(pHead!== null && pHead.next == null) return pHead let pre = null let cur = pHead while(cur) { let temp = cur.next cur.next = pre pre = cur cur = temp } return pre } module.exports = { ReverseList : ReverseList };



浙公网安备 33010602011771号