Developer

This experience deserves a bigger screen

The DSA Visualizer is designed for deep focus,
side-by-side code, and real-time execution insight.

On small screens, that level of clarity can't be preserved.

Open on a tablet (landscape) or desktop for the intended experience.

Desktop experience preview

Linked List CycleStep-by-Step Visualization

Floyd's Cycle-Finding Algorithm (Tortoise and Hare) is an ingenious way to detect cycles using two pointers moving at different speeds.

Problem Statement

Given head, the head of a linked list, determine if the linked list has a cycle in it.

Approach

Use two pointers, slow and fast. Slow moves one step at a time, fast moves two. If there is a cycle, the fast pointer will eventually catch up to the slow pointer within the cycle. If fast reaches the end (null), there is no cycle.

Time & Space Complexity

Time complexity is O(n). Space complexity is O(1).

Interactive Visualization

Loading Interactive Visualizer...

Click "Play" or use arrow keys to step through the execution.