Introduction
Given a singly linked list, find middle of the linked list. For example, if given linked list is 1->2->3->4->5 then output should be 3.
If there are even nodes, then there would be two middle nodes, we need to print second middle element. For example, if given linked list is 1->2->3->4->5->6 then output should be 4.
Approach
We use the tortoise and hare approach where we have a fast and a slow pointer. When the fast pointer reaches the end, the middle pointer reaches the middle position.