Skip to content

Commit 255dde0

Browse files
authored
Create README.md
1 parent b552941 commit 255dde0

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

Java/FloydAlgorithm/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Sample Input:
3+
4+
5
5+
6+
1 6 3 7 8
7+
8+
2
9+
10+
11+
12+
# Sample Output:
13+
14+
Loop exists
15+
16+
17+
18+
# Explaination:
19+
20+
4--> size of linked list
21+
22+
1-->6-->3-->7-->8 =>nodes of linked list
23+
24+
2---> node to be checked
25+
26+
</br>
27+
28+
after creating the loop the detect loop fuction is called and the two pointer slow and fast meets if loop exists .
29+
For better understanding,refer <a href="https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190621160855/Detect-loop-in-a-linked-list.png">here:
30+
31+
32+
# Time complexity:
33+
34+
O(n)

0 commit comments

Comments
 (0)