东方丽日 發表於 2026-4-3 18:27:00

206. 反转链表

<p>206. 反转链表</p>
<p>1:17:41</p>
<p><img alt="" loading="lazy"></p>
<pre><code class="language-js">/**
* Definition for singly-linked list.
* function ListNode(val, next) {
*   this.val = (val===undefined ? 0 : val)
*   this.next = (next===undefined ? null : next)
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var reverseList = function(head) {
    if(!head)return null;
    let pre=null,cur=head;
    while(cur){
      =
      // let next=cur.next;
      // cur.next=pre;
      // pre=cur;
      // cur=next;
    }
    return pre;
};
</code></pre>
<p>1</p><br><br>
来源:https://www.cnblogs.com/KooTeam/p/19818561
頁: [1]
查看完整版本: 206. 反转链表