Sort by

recency

|

984 Discussions

|

  • + 0 comments

    public static void reversePrint(SinglyLinkedListNode llist) { // Write your code here if (llist == null) return; // Base case for recursion

    reversePrint(llist.next); // Recursive call to the next node
    
    System.out.println(llist.data); // Print the current node after returning from recursion
    
    }
    
  • + 0 comments

    Kotlin:

    fun reversePrint(llist: SinglyLinkedListNode?): Unit {
        val list=ArrayList<Int>()
        var current=llist
        while(current!=null){
            list.add(current.data)
            current=current.next
        }
        list.reverse()
        list.forEach{
            println(it)
        }
    }
    
  • + 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

    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.