Tortoise And Hare Sample From Joma Tech

[Solved] Tortoise And Hare Sample From Joma Tech | Perl - Code Explorer | yomemimo.com
Question : tortoise and hare sample from Joma Tech

Answered by : nutty-narwhal-49yj2ihouz8y

def find_duplicates(nums): tortoise = nums[0] hare = nums[0] while True: tortoise = nums[tortoise] hare = nums[hare] if tortoise == hare: break ptr1 = nums[0] ptr2 = tortoise while ptr1 != ptr2: ptr1 = nums[ptr1] ptr2 = nums[ptr2] return ptr1
print(find_duplicates([1, 2, 3, 3, 4, 5, 6]))

Source : | Last Update : Thu, 28 Apr 22

Answers related to tortoise and hare sample from joma tech

Code Explorer Popular Question For Perl