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 find_mid() function which will take a linked list as an input and return the value of the middle node. If the length of the list is even, the middle value will occur at length2\frac{length}{2}. For a list of odd length, the middle value will be length2+1\frac{length}{2}+1.

Input

A singly linked list.

Output

The integer value of 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.