Skip to question
asic.fyi
DesignVerificationSystemVerilogFirmwareArchitectureInterviews
asic.fyi/Interview questions/Find the start of a cycle

Hardware interview practice

Find the start of a cycle

MediumLinked ListsPYTHON

Return the node where a linked-list cycle begins, or None when the list has no cycle.

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
1 -> 2 -> 3 -> 4, with node 4.next pointing to node 2
Expected output
node with value 2

After the first slow/fast meeting, advancing one pointer from head and one from the meeting point finds the cycle entry.

What to cover

Requirements

  1. Use constant extra space.
  2. Do not modify the list.
  3. Separate cycle detection from entry discovery.
Continue practicing

Related questions

Linked ListsReverse a singly linked list→Linked ListsDetect a linked-list cycle→Linked ListsFind the middle node→
asic.fyi · Learn silicon end to end.info@asic.fyi