Leetcode in Java && Oracle
419 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2021-11-13_20-43-54.png
51.6 KB
#N876. Middle of the Linked List
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;
}
}