Full explanation of the tortoise and hare algorithm AKA
Floyd’s algorithm for cycle detection.
This is part 2 of the tutorial for how to solve the common coding interview question “Find the Duplicate Number ” [LeetCode 287].
In part 1, I explained how to incrementally optimize the solution from naive to optimal.
Link to part 1
• Full Thought Process | LeetCode 287. Find ...
You can find the question here -
https://leetcode.com/problems/find-th...
This question has been asked in Amazon, Facebook and Google software engineering interviews (according to LeetCode)