Old but gold
There seems to be two different problems. But really, it's the same problem.
1. Find the repeating and non-repeating parts of the decimal expansion of 1/n.
1/3 = 0.(3)
1/6 = 0.1(6)
2. For a singly linked list, check whether it contains a cycle.
Share your thoughts and ideas in the comments. Use the “spoiler” feature wisely. I’ll publish the canonical approach in 3 days, if needed.
There seems to be two different problems. But really, it's the same problem.
1. Find the repeating and non-repeating parts of the decimal expansion of 1/n.
1/3 = 0.(3)
1/6 = 0.1(6)
2. For a singly linked list, check whether it contains a cycle.
Share your thoughts and ideas in the comments. Use the “spoiler” feature wisely. I’ll publish the canonical approach in 3 days, if needed.