Design an efficient algorithm that checks if a LinkedList, that holds a trillion elements, is circular or not.
Anonymous
The stack overflow answer, Tortoise and hare algorithm, of having a fast and slow node traversal is best as it's O(n). The other answers doesn't make sense because if you knew what the last node is, then you've already proven if it's circular or not. Without the benefit of google, I think logically, checking addresses or setting some sort of checked flag for every single node are both acceptable answers as they are O(n) but not as memory efficient O(1) vs. O(n). Personally, it would be very suspicious if someone tries to make it as if they came up with Floyd's algo right on the spot as there are math proofs that needs to be done. Hard to say which is the better answer, since the googled answer just proves that you're good at memorizing stuff vs. the more inefficient answer but that proves you understand performance and linked lists.
Check out your Company Bowl for anonymous work chats.