You are viewing a single comment's thread. Return to all comments →
I had a similar solution, except recursive and js. Not sure if there is a bug in this code or the solution checker:
var count = 0; var max = 100; function hasCycle(head) { if (head === null) { return false; } if (count > max) { return true; } count++; return hasCycle(head.next); }
edit: I guess there is a problem with state. Removing the recurrsion and encapsulating the counter passes ¯\_(ツ)_/¯
¯\_(ツ)_/¯
Seems like cookies are disabled on this browser, please enable them to open this website
Cycle Detection
You are viewing a single comment's thread. Return to all comments →
I had a similar solution, except recursive and js. Not sure if there is a bug in this code or the solution checker:
edit: I guess there is a problem with state. Removing the recurrsion and encapsulating the counter passes
¯\_(ツ)_/¯