You are viewing a single comment's thread. Return to all comments →
Yeah I wouldn't use recursion here unless I knew there was some limit on the size of the linked list.
Simple iterative C++ solution equivalent to surajdubey's Java:
#include <deque> void ReversePrint(Node *head) { deque<int> values; for (Node* current = head; current != 0; current = current->next) { values.push_front(current->data); } for (auto x : values ) { cout << x << endl; } }
Print in Reverse
You are viewing a single comment's thread. Return to all comments →
Yeah I wouldn't use recursion here unless I knew there was some limit on the size of the linked list.
Simple iterative C++ solution equivalent to surajdubey's Java: