Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ405
Page ↗
Q405FWASIC interview problem

Detect a linked-list cycle

TechniquesLinked listFast and slow
DifficultyEasy
TopicLinked Lists
LanguageSystemVerilog
Requirements3 checkpoints
01

Problem

Return 1 when a singly linked list contains a cycle and 0 when it terminates at null.

Example input and output

Use this case to check your interpretation
Input
1 -> 2 -> 3, with node 3.next pointing back to node 2
Output
1 (cycle present)
Explanation

The slow and fast pointers eventually meet inside the 2 -> 3 loop without modifying the list.

02

Requirements (3)

  • Use constant extra space.
  • Handle empty and one-node lists safely.
  • Do not modify list links.