4 ms·
If I was interviewing you, I would point out that you're redefined the question: the question gives you a standard linked list, and you state that you want a wr
by mankyd 12y ago
If I was interviewing you, I would point out that you're redefined the question: the question gives you a standard linked list, and you state that you want a wrapper-api around it. I would then ask you to try to find a solution that works for a bare bones linked list.
I would make a note that you did find one type of solution, of course.
edit: I would probably also ask why you created an api that even allows cycles, being as that you are defining control over adding and removing elements. Further, if you stated that your api explicitly allows cycles, I would ask why you don't simply mark them at insertion time and flag them, making the "detection" algorithm O(1).