Loading...

The Cycle Detector

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
junior, mid

Problem

Given a linked list represented as a list of nodes where each node points to the next by index (or -1 if it is the tail), determine if the list contains a cycle. A cycle exists if following the next pointers eventually revisits a node. Return True if a cycle exists, False otherwise.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a sandboxed Docker environment and grades it instantly.