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
Coding & Algorithms
Software Engineer
Uber
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

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
Linked lists
Floyd cycle detection
Two pointers
Proof
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample 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 O(n)O(n) 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...


Submit Your Answer
Markdown supported