Dsa
Linked List
Easy
Find Middle Element of Linked List
Given the head of a linked list, write a program to find and return the value of the middle node. If there are two middle nodes, return the second middle node.
Input Format:
The input consists of a line of space-separated integers representing the values of the linked list, followed by -1 to indicate the end.
Output Format:
Output the value of the middle node.
Example:
Input:
1 2 3 4 5 -1
Output:
3
Key concepts
linked_listmiddle
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now