class Solution {
public ListNode middleNode(ListNode head) {
ListNode slow=head,fast=head;
while(fast!=null&&fast.next!=null){
slow=slow.next;
fast=fast.next.next;
}
return slow;
}
}
通过使用快指针和慢指针,来索引到链接的中间位置
(其中while循环里面的条件是来判断返回第二个中间节点)