/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* ListNode next;
* ListNode(int x) { val = x; }
* }
*/
class Solution {
public ListNode middleNode(ListNode head) {
ListNode fast;
ListNode slow;
fast = head;
slow = head;
while (fast != null && fast.next != null) {
fast = fast.next.next;
slow = slow.next;
}
// slow 位置为中间节点
return slow;
}
}
08-20
519
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-20
389
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)