PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Amazon

Detect cycles in lists and graphs

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of cycle detection in linked lists and directed graphs, assessing competencies in pointer manipulation, graph traversal strategies, and reasoning about algorithmic time and space complexity within the Coding & Algorithms domain.

  • Medium
  • Amazon
  • Coding & Algorithms
  • Software Engineer

Detect cycles in lists and graphs

Company: Amazon

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

Given a singly linked list, determine whether it contains a cycle. Implement an O( 1)-space algorithm and explain the intuition and correctness. Follow-up: Generalize to a directed graph where each node may have multiple children. Given a starting node, determine whether a cycle exists reachable from it. Discuss how you'd handle disconnected graphs, very large graphs that may not fit in memory, and the time/space complexity trade-offs. Provide pseudocode or code for both parts.

Quick Answer: This question evaluates understanding of cycle detection in linked lists and directed graphs, assessing competencies in pointer manipulation, graph traversal strategies, and reasoning about algorithmic time and space complexity within the Coding & Algorithms domain.

Related Interview Questions

  • Implement Datacenter Router Commands - Amazon (hard)
  • Replace Delimited Tokens in a String - Amazon (medium)
  • Minimize Circular Redistribution Cost - Amazon (medium)
  • Find the Most Common Visit Pattern - Amazon (hard)
  • Maximize Value Under a Budget - Amazon (medium)
Amazon logo
Amazon
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
2
0

Given a singly linked list, determine whether it contains a cycle. Implement an O( 1)-space algorithm and explain the intuition and correctness. Follow-up: Generalize to a directed graph where each node may have multiple children. Given a starting node, determine whether a cycle exists reachable from it. Discuss how you'd handle disconnected graphs, very large graphs that may not fit in memory, and the time/space complexity trade-offs. Provide pseudocode or code for both parts.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Amazon•More Software Engineer•Amazon Software Engineer•Amazon Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.