You are viewing a single comment's thread. Return to all comments →
here's my solution in C language:
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* node = malloc(sizeof(SinglyLinkedListNode)); node->data = data; node->next = llist; llist = node; return llist; }
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Insert a node at the head of a linked list
You are viewing a single comment's thread. Return to all comments →
here's my solution in C language:
SinglyLinkedListNode* insertNodeAtHead(SinglyLinkedListNode* llist, int data) { SinglyLinkedListNode* node = malloc(sizeof(SinglyLinkedListNode)); node->data = data; node->next = llist; llist = node; return llist; }