Skip to content

DN-Pixel/FloydTortoiseAndHare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Floyd's tortoise and hare

Function allowing you to find duplicate in an array in linear time and constant space !

Floyd's method is pretty amazing, allowing you to find a duplicate number. Given an array : "array" (of size n) containing n+1 integers, where each integer is beetween 1 and n (inclusive).
One duplicate number MUST exist (simple logic) : FIND IT.

Got the idea from this video !