344. Middle of the Linked List
0
Easy
Given the head of a singly linked list, find and return the middle node of the linked list. If there are two middle nodes, return the second middle node.
Input Format
The first line contains an integer n, representing the number of nodes in the linked list. The next line contains n space-separated integers, representing the values of the nodes.
Output Format
Print the value of the middle node of the linked list.
Example
Input
1 2 3
Output
2
Constraints
The number of nodes in the linked list is between 1 and 100, inclusive. Each node's value is an integer between 1 and 100, inclusive.
Loading...
View Submissions
Console