Question

How do you find middle element of a linked list in single pass?

Hint

First, start with the simple solution on which you traverse the LinkedList until you find the tail of linked list where it points to null to find the length of linked list and then reiterating till middle.

Answer

Possible solution: use two pointers one incrementing one step at a time and other incrementing two step a time, so when first pointer reaches end of linked second pointer will point to the middle element.