Challenge: Find Middle Node of Linked List

Here's another interesting coding challenge to test your knowledge on linked lists.

Problem Statement

You have to implement the findMid() function, which will take a linked list as an input and return the middle node. If the length of the list is even, the middle value will occur at length2\dfrac{length}{2}. For a list of odd length, the middle value will be length2+1\dfrac{length}{2}+1.

Input

A singly linked list.

Output

The middle node.

Sample Input

LinkedList = 7->14->10->21

Sample Output

14

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.