Dashboard
LC #876

Middle of the Linked List

Pattern · ?AmazonGoogleMicrosoft

Problem

Find the middle node of a linked list in one pass.

Constraints

  • 1 ≤ n ≤ 100
  • 1 ≤ Node.val ≤ 100

Example

Input
head = [1, 2, 3, 4, 5]
Output
[3, 4, 5]
Why
Middle node is 3 (index 2). For [1,2,3,4,5,6], return node 4 (second middle)

Spot the pattern

Which pattern cracks it?

Hints

One at a time
Solve on LeetCode ↗