2dbi
Home/Intel/Detect a Cycle in a Linked List
IIntel·DSASDE-2Onsite – Coding 2

Detect a Cycle in a Linked List

Problem

Determine whether a singly linked list has a cycle, in O(1) extra space.

Example

Floyd's tortoise and hare

Constraints

  • 0 ≤ nodes ≤ 10^4

Follow-up

Return the node where the cycle begins and explain the math.

added 6 days ago
LeadersAccount