Pergunta de entrevista da empresa American Express

How do you detect a cycle in a singly linked list?

Resposta da entrevista

Sigiloso

23 de jan. de 2026

use the tortoise and hare method. Slow pointer should move one tile at a time and the fast pointer moves two tiles. If the fast pointer catches up to the slow pointer then there is a cycle but if the fast pointer reaches null, there is no cycle.