Blogger

Delete comment from: Javarevisited

Maruti said...

I think the best way to find the cycles is
traverse from the begining and check in map if the node pointer is in hashmap if present then its cyclic else put the node pointer and move to next.

if you reach till end and you didnt find any duplicate entry in hashmap/hashtable then its not cyclic.. correct me if I am wrong..

Jul 25, 2013, 8:23:16 AM


Posted to How to find If Linked List Contains Loop or Cycle in Java? Example Solution

Google apps
Main menu