Ctrl K

Midpoint of a List

Easy
You get a non-empty singly linked list whose first node is start. Return the node that sits exactly in the middle. If the list has an even number of nodes, there are two middle nodes; return the second one (the one closer to the end). You return the node itself, so the whole tail starting from it is what gets checked.
Example 1
start=list_node([7, 4, 9]) → [4, 9]

The middle node is the second one, holding 4; from there the list reads [4, 9].

Example 2
start=list_node([12, 5, 30, 8]) → [30, 8]

There are two middle nodes, 5 and 30; the second one is required, so the answer starts at 30.

Example 3
start=list_node([42]) → [42]
Constraints
  • The list has between 1 and 100 nodes
  • 1 ≤ Node.val ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSymmetric Bead String EasyDrop the K-th Node From the Tail MediumMove the Tail to the Front MediumSorted List, Unique Values Only MediumSplit a List Around a Pivot Medium
loading Python…
Input
start=list_node([7, 4, 9])
Expected
[4, 9]

Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.