Sort by

recency

|

978 Discussions

|

  • + 0 comments

    Lots off problems with de code given in c#.

  • + 0 comments

    Here is my c++ solution, you can watch the vidéo explanation here : https://youtu.be/WO7Uz7sQML4

    void reversePrint(SinglyLinkedListNode* llist) {
        if(llist == nullptr) return;
        reversePrint(llist->next);
        cout << llist->data << endl;
    }
    
  • + 0 comments

    simplest python solution:

    def reversePrint(llist):
        if not llist:
            return
            
        reversePrint(llist.next)
        print(llist.data)
    
  • + 0 comments
    void reversePrint(SinglyLinkedListNode* head) {
        SinglyLinkedListNode *temp=head;
        int i=0;
        while(temp!=NULL){
            i++;
            temp=temp->next;
        }
        temp=head;
        int arr[i];
        for(int k=0; k<i; k++){
            arr[k]=temp->data;
            temp=temp->next;
        }
        for(int j=i-1; j>=0; j--){
            printf("%d\n",arr[j]);
        }
    }
    
  • + 0 comments

    Here is a recursive solution in JavaScript:

    function reversePrint(llist) {
        if (!llist) {
            return;
        }
        
        reversePrint(llist.next)
        console.log(llist.data);    
    }