hacking-tools-scriptss/Java/FloydAlgorithm at main · sanscript-tech/hacking-tools-scriptss · GitHub
Skip to content

Latest commit

 

History

History
 
 

FloydAlgorithm

Folders and files

README.md

Sample Input:

5

1 6 3 7 8

2

Sample Output:

Loop exists

Explaination:

4--> size of linked list

1-->6-->3-->7-->8 =>nodes of linked list

2---> node to be checked


after creating the loop the detect loop fuction is called and the two pointer slow and fast meets if loop exists . For better understanding,refer here:

Time complexity:

O(n)