You are viewing a single comment's thread. Return to all comments →
This is my answer and it works perfectly fine in C++:
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* head=new SinglyLinkedListNode(data); head->next=llist; return head;
}
Insert a node at the head of a linked list
You are viewing a single comment's thread. Return to all comments →
This is my answer and it works perfectly fine in C++:
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* head=new SinglyLinkedListNode(data); head->next=llist; return head;
}