找到链表的中间节点
题目描述
给定一个单链表,求中间节点。
public ListNode
findMid(ListNode head
){
ListNode slow
=head
;
ListNode fast
=head
;
while(fast
.next
!=null
&&fast
.next
.next
!=null
){
slow
=slow
.next
;
fast
=fast
.next
.next
;
}
return slow
;
}
转载请注明原文地址: https://lol.8miu.com/read-2724.html