Why increase pointer by two while finding loop in linked list, why not 3,4,5?

From a correctness perspective, there is no reason that you need to use the number two. Any choice of step size will work (except for one, of course). However, choosing a step of size two maximizes efficiency. To see this, let’s take a look at why Floyd’s algorithm works in the first place. The idea … Read more