Locate Where a Corrupted Linked Job Queue Starts Looping
Last updated: November 29, 2026
Quick Overview
A bug may have created a cycle in a singly linked job queue. Return the node where the cycle begins, or None if the queue is acyclic, using O(1) extra space.
Meta
November 29, 20260
0
0 solved
A bug may have created a cycle in a singly linked job queue. Return the node where the cycle begins, or None if the queue is acyclic, using O(1) extra space.
Asked in Meta technical screens as a pointer-reasoning question, framed around a corrupted in-memory queue of background jobs that a worker would otherwise process forever. The interviewer wants Floyd's tortoise and hare and, importantly, the argument for why resetting one pointer to head finds the cycle entry.
What the Interviewer Expects
- Detect a cycle with slow and fast pointers
- Find the entry by restarting one pointer from head
- Prove why the second phase meets at the entry
- Offer the hash set alternative and its space cost
- Return None cleanly for acyclic lists
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Return the length of the cycle as well.
- Break the cycle so the queue becomes a proper list.
- How would you detect this in production without stopping the worker?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: head of a singly linked list that may contain a cycle. Output: the first node in the cycle (the node reachable from head that is reached twice when walking), or None. Do not modify the list; O(...
High-Level Design
Phase 1: slow moves one step, fast two. If fast hits None there is no cycle. Otherwise they meet inside the cycle. Phase 2: let a be the distance from head to the entry, b the distance from the entry ...