Middle of a Linked List
Updated
Problem statement
You are given the head of a singly linked list. Return the middle node of the list.
If the list has two middle nodes, return the second one. The answer is shown as the values from the returned node to the tail.
Function
middleNode(head: ListNode) → ListNodeExamples
Example 1
head = [4,8,15,16,23]return = [15,16,23]Removed
Moved or new
The list has 5 nodes, so the middle is the third node, 15. From there the list reads 15, 16, 23.
Example 2
head = [3,1,4,1,5,9]return = [1,5,9]Removed
Moved or new
The list has 6 nodes, so there are two middle nodes: the third (4) and the fourth (1). Return the second one, the fourth node. From there the list reads 1, 5, 9.
Example 3
head = [42]return = [42]A single node is its own middle.
Constraints
- The number of nodes in the list is in the range
[1, 100]. 1 <= Node.val <= 100
More Cisco interview questions
- Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
- Find Unique ElementsPHONE SCREEN · Seen Nov 2026
- First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a StringPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
- Longest Non-Repeating SubstringPHONE SCREEN · Seen Jul 2026
- Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
- Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Merge Two Sorted ListsIBM · PHONE SCREENIBM interview questions
- Count Nodes in a ChainApple · PHONE SCREENApple interview questions
- Detect a Cycle in a Linked ListSalesforce · PHONE SCREENSalesforce interview questions
- Find the Intersection Node of Two Linked ListsVisa · PHONE SCREENVisa interview questions
- Reverse a Linked ListMygate · PHONE SCREENMygate interview questions
- Find the Intersection Node of Two Linked ListsLinkedIn · PHONE SCREENLinkedIn interview questions
- Linked List Palindrome in Constant SpaceNVIDIA · PHONE SCREENNVIDIA interview questions
- First Node Two Linked Lists ShareAdobe · PHONE SCREENAdobe interview questions
- Reverse a Singly Linked ListBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Merge Two Sorted Linked ListsExpedia · PHONE SCREEN · ONSITE INTERVIEWExpedia interview questions