Loading the journal
Loading the journal
Cycle Detection (Floyd's Tortoise and Hare)Solved Oct 26, 2025
Problem
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive). Assume there is only one duplicate number, find and return this duplicate. The solution must use O(1) extra space and run in less than O(n²) time.
Reading the solution first feels like progress, but it makes the next similar problem — and the interview version — much harder, because you skipped the part where you figure it out. Give it an honest 20–30 minutes. Stuck? Re-read the pattern, watch the concept video, or try the brute force first.
Hidden: approach · solution code