Locate Where a Corrupted Redirect Chain Starts Looping

Last updated: November 29, 2026

Quick Overview

A crawler follows a chain of redirects modeled as a singly linked list, and a misconfiguration may make the chain loop back on itself. Return the first node of the loop (or None if there is none) using O(1) extra memory.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


A crawler follows a chain of redirects modeled as a singly linked list, and a misconfiguration may make the chain loop back on itself. Return the first node of the loop (or None if there is none) using O(1) extra memory.

A Google technical screen favorite in a crawler framing, since redirect loops are a real Googlebot concern. The interviewer wants Floyd's algorithm and, more importantly, a clear proof of why resetting one pointer to the head finds the loop entry.

What the Interviewer Expects
  • Detect the loop with slow and fast pointers
  • Reset one pointer to the head and step both by one to find the entry
  • Prove the entry step using distances (a = kL - b)
  • Contrast with the O(n) space visited-set approach
  • Also report the loop length if asked
Key Topics to Cover
linked list
cycle detection
Floyd's algorithm
fast and slow pointers
proof of correctness
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
  • Return the length of the loop as well.
  • The redirect graph is given as a dict from URL to URL rather than nodes. What changes?
  • How would Googlebot handle this in production without walking a chain forever?
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 that may contain a cycle.
  • Output: the node where the cycle begins, or None.
  • O(1) extra space; do not modify the list....
High-Level Design

Phase 1: move slow one step and fast two steps. If fast reaches None there is no loop. Otherwise they meet inside the loop. Phase 2: let a be the distance from head to the loop entry, b the ...


Submit Your Answer
Markdown supported