Kumar-laxmi / Algorithms

A Repository for algorithms in C, C++, Python and Java
Apache License 2.0
326 stars 367 forks source link

Fast and Slow approch in Linked list #1732

Closed dontwike closed 1 year ago

dontwike commented 1 year ago

Is your feature request related to a problem? Please describe. Yes, I want to implement fast and slow approach in the linked list which helps in finding loop in a linked list

Describe the solution you'd like We take 2 pointers in a linked list fast and slow, where fast moves two steps in every turn and slow moves a single step in every turn, both the pointer meets in the list if only there is a loop available otherwise the goes till null.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Helps in finding a loop in Linked List and a node in a cycle.

Assign me this issue under SSOC

Kumar-laxmi commented 1 year ago

This has been implemented