var reverseList = function(head) {
let current = head;
let pre = null;
let t = null;
while(current){
t = current.next;
current.next = pre; //改变表头链表指向
pre = current;
current = t;
}
return pre;
};
【leetcode-js】反转链表
最新推荐文章于 2024-08-15 05:02:54 发布