• + 6 comments

    Am I the only crazy person here who didn't even thought of recursion and created another reversed LinkedList just to output the characters in reverse order? :/

    void ReversePrint(Node *head)
    {
        struct Node* last = NULL;
        while(head != NULL) {
            struct Node* temp = new Node;
            temp->data = head->data;
            temp->next = last;
            last = temp;
            head = head->next;
        }
        
        while(last != NULL) {
            cout<<last->data<<endl;
            last = last->next;
        }
    }