141 Linked List Cycle – Medium
Problem:
Given a linked list, determine if it has a cycle in it.
Follow up: Can you solve it without using extra space?
Thoughts:
A very classic problem to use two pointers.Slow fast pointers. One pointer moves one forward each time and the other one moves two forward each time.
If there is a cycle, they will eventually meet. If there is no cycle, the faster pointer will meet null eventually.
Solutions:
Last updated