You are viewing a single comment's thread. Return to all comments →
Straightforward, somewhat efficient iterative solution in JavaScript using an array as a stack:
function getNodeValue(head, position) { var stack = []; var curNode = head; while(curNode) { stack.push(curNode.data); curNode = curNode.next; } while(position) { stack.pop(); position--; } return stack.pop(); }
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 →
Straightforward, somewhat efficient iterative solution in JavaScript using an array as a stack: