We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Unrelatedly; no PHP version available? Why? Nothing stops you making a simple linked list if you want to. I was looking forward to abusing its built-in behaviour:
classNode{public$data;public$nextNode;}$node=newNode();$node->data='foo';$node->nextNode=newNode();$node->nextNode->nextNode=$node;// <- cycle introducedob_start();// var_dump() will print '*RECURSION*' in place of a cyclic referencevar_dump($node);$s=ob_get_clean();// ignore closing braces etc$s=str_replace(['}',"\t","\n",' ',"\r"],[''],$s);$s=substr($s,-11,11);echo($s=='*RECURSION*')?1:0;// <- cycle detected
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Linked Lists: Detect a Cycle
You are viewing a single comment's thread. Return to all comments →
That '100' looked exploitable to me too, I was lazier still:
Unrelatedly; no PHP version available? Why? Nothing stops you making a simple linked list if you want to. I was looking forward to abusing its built-in behaviour: