链表的中间结点-876


力扣(LeetCode) 链接:https://leetcode.cn/problems/middle-of-the-linked-list/discussion/

var middleNode = function (head) {
  let slow = head
  let fast = head
  while (fast !== null && fast.next !== null) {
    slow = slow.next
    fast = fast.next.next
  }
  return slow
}

文章作者: 高红翔
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 高红翔 !
  目录