You have a linked list. How would you detect a loop in it, without using DFS of BFS?
Anonymous
Use two iteratiors. One will go with the speed of 1 cell/iteration, the other one with the speed of 2 cells/iteration. If they meet, then we have a loop.
Check out your Company Bowl for anonymous work chats.