image_2021-11-13_20-43-54.png
51.6 KB
#N876. Middle of the Linked List
problem link
#solution
problem link
#solution
class Solution {
public ListNode middleNode(ListNode head) {
ListNode temp=head;
int length=0;
while(temp!=null){
temp=temp.next;
length++;
}
for(int i=1; i<=length/2; i++)
head=head.next;
return head;
}
}