876. 链表的中间结点

题目链接:https://leetcode-cn.com/problems/middle-of-the-linked-list/

执行用时:0 ms, 在所有 Swift 提交中击败了100.00% 的用户
内存消耗:13.4 MB, 在所有 Swift 提交中击败了75.94% 的用户

1
2
3
4
5
6
7
8
9
10
class Solution {
func middleNode(_ head: ListNode?) -> ListNode? {
var s = head, f = head
while f?.next != nil {
f = f?.next?.next
s = s?.next
}
return s
}
}

876. 链表的中间结点
https://pisces34.github.io/2021/08/22/leetcode/876/
发布于
2021年8月22日
许可协议