You are viewing a single comment's thread. Return to all comments →
c++ solution using stack
void reversePrint(SinglyLinkedListNode* llist) { std::stack<int> stack; SinglyLinkedListNode* node = llist; while (node != NULL) { stack.push(node->data); node = node->next; } while (!stack.empty()) { printf("%d\n", stack.top()); stack.pop(); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
c++ solution using stack