You are viewing a single comment's thread. Return to all comments →
JS code :
function getNode(llist, positionFromTail) { let current = llist; let reverse = null; let temp = null; if(!llist) return llist; while(current !== null){ temp = current.next; current.next = reverse; reverse = current; current = temp; } let currentIndex = 0; let current2 = reverse; while(current2 !== null){ if(currentIndex === positionFromTail) break; currentIndex++; current2 = current2.next; } return current2.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 →
JS code :