You are viewing a single comment's thread. Return to all comments →
Solved easily using an array as a stack to reverse the order of all values. JavaScript solution:
function reversePrint(head) { var dataStack = []; var curNode = head; while(curNode) { dataStack.push(curNode.data); curNode = curNode.next; } while(dataStack.length > 0) { console.log(dataStack.pop()); } }
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
Solved easily using an array as a stack to reverse the order of all values. JavaScript solution: