You are viewing a single comment's thread. Return to all comments →
Brilliant!!
Here is my code in java based on your algorithm.
int GetNode(Node head, int n) { Node pointer = head; int pointerPosition = 0; while (head.next != null){ head = head.next; if (pointerPosition < n){ pointerPosition++; }else { pointer = pointer.next; } } return pointer.data; }
Seems like cookies are disabled on this browser, please enable them to open this website
Get Node Value
You are viewing a single comment's thread. Return to all comments →
Brilliant!!
Here is my code in java based on your algorithm.