Challenge 7: Find Middle Node of Linked List
This is another coding challenge that tests your knowledge on linked lists.
Problem statement
You have to implement the FindMid()
function, which is a member function of a LinkedList
, and it should return the value of the middle node. If the length of the list is even, the middle value will occur at . For a list of odd length, the middle value will be .
Input
A linked list is the input.
Output
Middle element of the linked list is the output.
Sample input
LinkedList = 7->14->10->21->null
Sample output
14
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.