Find Where a Looping Shuttle Route Re-Enters Its Cycle
Last updated: November 29, 2026
Quick Overview
A shuttle route is modeled as a singly linked list of stops that may loop back onto an earlier stop. Return the stop node where the loop begins, or None if the route ends, using O(1) extra space.
Uber
November 29, 20260
0
0 solved
A shuttle route is modeled as a singly linked list of stops that may loop back onto an earlier stop. Return the stop node where the loop begins, or None if the route ends, using O(1) extra space.
An Uber technical screen question about detecting bad route data, such as a corrupted next-stop pointer that sends a shuttle in circles. The interviewer wants Floyd's algorithm and, importantly, the proof of why the second phase finds the entry.
What the Interviewer Expects
- Detects a cycle with slow and fast pointers
- Resets one pointer to the head after they meet
- Explains the distance argument for the second phase
- Uses O(1) space rather than a visited set
- Handles a cycle that starts at the head
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
- How would you compute the loop length?
- How would you break the loop to repair the route?
- When would a visited set be the better engineering choice?
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. Output: the node where the cycle begins (by identity), or None. O(1) extra space. A hash set of visited nodes is the space baseline....
High-Level Design
Phase 1: move slow by one and fast by two. If fast hits the end, there is no loop. If they meet, there is one. Phase 2: put one pointer at the head and keep the other at the meeting point, then move b...