FastPrepMiddle Node Of A Linked List
Problems/Middle Node Of A Linked List

Middle Node Of A Linked List

NVIDIA logoNVIDIA● EasyFULLTIMEONSITE INTERVIEW
QuestionFunctionExamplesConstraints

Problem statement

Source note: The report asked for the middle node of a linked list. The judged core task matches the visible source at about 99%; even-length second-middle rule, examples, and numeric bounds are specified for practice.

You are given the head of a singly linked list.

Return the middle node of the list. If the list has an even number of nodes, return the second of the two middle nodes.

The returned node is the start of the suffix that begins at the middle; callers observe the remaining values from that node to the end.

Function

middleNode(head: ListNode) → ListNode

Examples

Example 1

head = [1,2,3,4,5]return = [3,4,5]

The list has five nodes. The middle node holds 3, so the remaining suffix is 3 -> 4 -> 5.

Example 2

head = [1,2,3,4,5,6]return = [4,5,6]

The list has six nodes, so the two middle nodes hold 3 and 4. The judged answer is the second middle, 4 -> 5 -> 6.

Constraints

  • The number of nodes is in the range [1, 100].
  • 1 <= node.val <= 100.

More NVIDIA problems

  • Summarize Server Healthcheck LogsPHONE SCREEN · Seen Oct 2026
  • Query a Header-Encoded MatrixOA · Seen Oct 2026
  • Maximum ScoreOA · Seen Oct 2026
All NVIDIA interview questionsSee NVIDIA hiring insights
Saved
/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode() {}
 *     ListNode(int val) { this.val = val; }
 *     ListNode(int val, ListNode next) { this.val = val; this.next = next; }
 * }
 */
class Solution {
    public ListNode middleNode(ListNode head) {
      // Write your code here.
    }
}
Checking account…