Data Structure Linked list Question:
Download Questions PDF

Do you know how to find if linked list has loop?

Linked list Interview Question
Linked list Interview Question

Answer:

This question has bit of similarity with earlier algorithm and data structure interview question. I mean we can use two pointer approach to solve this problem. If we maintain two pointers, and we increment one pointer after processing two nodes and other after processing every node, we are likely to find a situation where both the pointers will be pointing to same node. This will only happen if linked list has loop.

Download Linked list Interview Questions And Answers PDF

Previous QuestionNext Question
Tell me how to find middle element of linked list in one pass?Explain how to find 3rd element from end in a linked list in one pass?