Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Find the middle node

Hardware interview practice

Find the middle node

EasyLinked ListsSystemVerilog

Return the middle node of a singly linked list. For an even-length list, return the second of the two middle nodes.

Try it in the question bankReason first. Then compare.

Keep this exact question selected while you check your answer and review the full solution.

Practice this question →
Reviewed example

Work through one case

Input
head = 1 -> 2 -> 3 -> 4 -> null
Expected output
node with value 3

With an even number of nodes, the fast pointer reaches null after slow advances to the second middle node.

What to cover

Requirements

  1. Use one traversal.
  2. Use constant extra space.
  3. Return null for an empty list.
Continue practicing

Related questions

Linked ListsDetect a linked-list cycle→Linked ListsReverse a singly linked list→Linked ListsMerge two sorted linked lists→
asic.fyi · Learn silicon end to end.info@asic.fyi