Answered Questions

  • how to find the loop in singly linked list

    if we are having the singly linked list then last node of the list is linked with middle (or) any node in the list then it causes the loop then how to find the loop with less time complexity

    prasanjeet

    • Aug 25th, 2011

    Take 2 pointers (say p & q) pointing to the start of the list. Increment p by one and q by 2 till p and q points to the same node (in case of loop) or one of them reaches the end (in case of no loop).