Sort by

recency

|

982 Discussions

|

  • + 0 comments

    This is the perfect way to understand recursive

    public static void reversePrint(SinglyLinkedListNode llist) { if(llist != null){ reversePrint(llist.next); System.out.println(llist.data); } }

  • + 0 comments

    Third issue with C# template here... hackerrank, what's up with that? You need good C# coders to fix up your templates????

    Solution:

    Same as prior problem

    remove class Result, but keep its guts. change function to be non-public -- remove public keyword.

  • + 0 comments

    solution with javascript

    function reversePrint(llist) {
        var i =0;
        var arr = []
            let currentNode = llist
            while(currentNode!==null){
                i++;
               currentNode = currentNode.next;
            }
             currentNode = llist;
            for(let j = 0;j<i;j++){
                arr.unshift(currentNode.data);
                currentNode = currentNode.next;
            }
           for(let j=0;j<i;j++){
            console.log(arr[j])
           }
        // Write your code here
    
    }
    
  • + 0 comments

    function reversePrint(llist) { var i =0; var arr = [] let currentNode = llist while(currentNode!==null){ i++; currentNode = currentNode.next; } currentNode = llist; for(let j = 0;j

    }

  • + 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;
    }