Algorithm Spotlight: Floyd’s Cycle Detection Algorithm

Learn about Floyd’s Cycle Detection Algorithm!

Last Updated: March 8, 2021

Source

The Problem Statement

Source: Linked List Cycle (LeetCode)
Input: head = [3,2,0,-4], pos = 1
Output: true
Explanation: There is a cycle in the linked list, where tail connects to the second node.

Idea 1: Use a Set

Idea 2: Floyd’s Cycle Detection Algorithm

Implementing Floyd’s Cycle Detection Algorithm

Problems

Thanks for reading! Don’t miss out on the next episode of Algorithm Spotlight!

Living in The Milky Way 😀