Linked List Cycle Detection with Two Pointers

Day 37 of DSA – Linked List Cycle Today I solved Linked List Cycle using the Two Pointer technique (Floyd’s Algorithm). Instead of using extra space (like a HashSet), I learned how to: Use a slow pointer (moves 1 step) Use a fast pointer (moves 2 steps) Detect a cycle when both pointers meet 💡 Key Insight: If there is no cycle → fast pointer reaches null. If there is a cycle → fast eventually catches slow. Time Complexity: O(n) Space Complexity: O(1) This problem strengthened my understanding of pointer movement and loop detection in linked lists. #100DaysOfCode #DSA #Java #LinkedList #LeetCode #ProblemSolving

  • graphical user interface, text, application, email

To view or add a comment, sign in

Explore content categories