Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Middle of the Linked List

Easy
linked-listtwo-pointers

Given the head of a singly linked list, return the middle node (the second middle if there are two). The output prints the list from that node to the end.

Input: one line of space-separated integers — the list values. Output: values from the middle node onward, space-separated.

Example 1
Input:
1 2 3 4 5
Output:
3 4 5
Example 2
Input:
1 2 3 4 5 6
Output:
4 5 6

Two middles (3, 4) — return the second.

Constraints

  • 1 ≤ list length ≤ 100
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.