You are viewing a single comment's thread. Return to all comments →
A different recursive solution. Uses pass-by-reference.
int GetNode(Node *head, int & positionFromTail) { if (head == NULL) return 0; int answer = GetNode(head->next, positionFromTail); if (positionFromTail == -1) { return answer; } else { --positionFromTail; return head->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 →
A different recursive solution. Uses pass-by-reference.