Code is given in the comment section.
Prerequisite:
1)Theory concept to detect a loop in linked list
https://www.techiedelight.com/detect-...
2)Practice problem based on loop detection concept :
i)Intersection Point in Y Shapped Linked Lists | JAVA | HashSet
• Intersection Point in Y Shapped Linke...
ii)Find length of Loop | JAVA | Linked List
• Find length of Loop | JAVA | Linked List