Middle of the Linked List Problem

Middle of the Linked List Problem — ExecCode Easy DSA Practice

Solve the Middle of the Linked List problem on ExecCode. Free online easy DSA practice in Linked List. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node.

Examples

Input head = [1, 2, 3, 4, 5]; Output [3, 4, 5]. Input head = [1, 2, 3, 4, 5, 6]; Output [4, 5, 6]. Input head = [1]; Output [1]

Constraints

The number of nodes in the list is in the range [1, 100]. 1 ≤ Node.val ≤ 100

Practice Middle of the Linked List free on ExecCode. Browse DSA problems, topic map, and placement guides.