Sort by

recency

|

903 Discussions

|

  • + 0 comments

    Fourth broken C# template.

    Remove class result but keep its guts. make reverse function non-public (remove public keyword).

    Geeze hackerrank -- didn't expect it that bad. And you guys test for our ability to program?

  • + 0 comments

    Here is my c++ solution, you can watch video explanation here : https://youtu.be/F4nGusqPIu0

    SinglyLinkedListNode* reverse(SinglyLinkedListNode* llist) {
        SinglyLinkedListNode* reverse = nullptr;
        while(llist != nullptr){
            SinglyLinkedListNode* newNode = new SinglyLinkedListNode(llist->data);
            newNode ->next = reverse;
            reverse = newNode;
            llist = llist->next;
        }
        return reverse;
    }
    
  • + 0 comments

    Cannot be solved via c#, its broken. Fields for the node needs to be changed to nullable.

  • + 0 comments

    Language: Java ☕

    Video solution:
    https://www.youtube.com/watch?v=5Dbh0dXG6-c

    Recursive approach

    Time complexity:
    Space complexity:

    What do you think? 😀

  • + 0 comments

    recursive python solution:

    def reverse(llist):
        if llist == None or llist.next == None:
            return llist
            
        new_head = reverse(llist.next)
        llist.next.next = llist
        llist.next = None
        
        return new_head