Middle of the Linked List
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.

30:00

Middle of the Linked List
easy
Topics
Companies

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.

Example 1:
Input: [1,2,3,4,5]
Output: [3,4,5]
Constraints:
  • The number of nodes is in the range [1,100][1, 100].

  • 1Node.val1001 \leq \text{Node.val} \leq 100

Input
arr =[1,2,3,4,5]

Find middle of list with 5 nodes

Slow
Fast
Middle
SF

1

0

2

1

3

2

4

3

5

4

null

Slow moves 1 step, Fast moves 2 steps

Variables
No variables to display
DepthFunction Call
Stack empty
0/5