Skip to content

原题链接

LeetCode;

typescript
function middleNode(head: ListNode | null): ListNode | null {
  // 1.转成数组 2.两次遍历
  // 3. 双指针

  let slow = head;
  let fast = head;

  while(fast && fast.next) {
      slow = slow.next;
      fast = fast.next.next
  }

  return slow;
};