Insert a node at the head of a linked list

Sort by

recency

|

975 Discussions

|

  • + 0 comments

    The c# method has error here :: PrintSinglyLinkedList(llist->head, "\n", textWriter);

    The -> operator is not allowed c# (pointer only for c/c++).

    Use another compiler.

  • + 0 comments

    The C# doesn't compile. Seeing this error even without my code:

    Solution.cs(32,25): warning CS8625: Cannot convert null literal to non-nullable reference type.

  • + 0 comments

    compile failure in C# code

  • + 0 comments

    Here is my c++ solution you watch vide explanation here : https://youtu.be/COnfpdhOlN8

    SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) {
       SinglyLinkedListNode* new_node = new SinglyLinkedListNode(data);
       new_node -> next = llist;
       return new_node;
    }
    
  • + 0 comments
    def insertNodeAtHead(head, data):
        node = SinglyLinkedListNode(data)
        node.next = head
        
        return node