Skip to content
On this page

2095. 删除链表的中间节点

原题链接:LeetCode 2095. 删除链表的中间节点

题解代码

javascript
var deleteMiddle = function(head) {
  if (!head.next) return null
  let slow = head, fast = head.next
  while (fast && fast.next && fast.next.next) {
    slow = slow.next
    fast = fast.next.next
  }
  slow.next = slow.next.next
  return head
};

技术文档集合