DataDriven
LearnPracticeInterviewDiscussDailyJobs

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
L3

Problem

Given a list where each index i has next_pointers[i] = next index (or -1 for tail), return True if starting from any index leads to a cycle. Actually: follow starting from index 0 and detect whether any index is revisited before hitting -1 or out-of-range.

Summary

Follow the chain long enough and you might end up where you started.

Practice This Problem

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

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons