
本文共 1467 字,大约阅读时间需要 4 分钟。
������������
������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������
������������
������������������������������������������������������������������������������������������������������������������������������������������������������
/*function ListNode(x){ this.val = x; this.next = null;}*/function ReverseList(pHead){ let temp = []; while(pHead){ temp.unshift(pHead.val); pHead = pHead.next; } if(temp.length == 0){return pHead;} let head = new ListNode(temp[0]); let res = head; for(let i=1; i
������
���������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������pre
���cur
���������������������cur
���������������������������������������cur.next
���������������������������������������������cur.next
���������������������������������������������������������������������������cur.next=pre
���������������������������������������������������������������������
/*function ListNode(x){ this.val = x; this.next = null;}*/function ReverseList(pHead){ if(!pHead || !pHead.next){return pHead;} let cur = pHead.next; let pre = pHead; pre.next = null; while(cur){ let temp = cur.next; cur.next = pre; pre = cur; cur = temp; } return pre;}
发表评论
最新留言
关于作者
