3 ms·
There are a bunch of algorithms for detecting cycles. One of the classics is the tortoise and hare algorithm, which uses only O(1) space. https://en.wikipedia.o
by ufo 4y ago
There are a bunch of algorithms for detecting cycles. One of the classics is the tortoise and hare algorithm, which uses only O(1) space. https://en.wikipedia.org/wiki/Cycle_detection#Floyd's_tortoise_and_hare https://en.wikipedia.org/wiki/Cycle_detection#Floyd's_tortoi...
- deleted 4y ago[deleted]