You are viewing a single comment's thread. Return to all comments →
In c++
SinglyLinkedListNode* insertNodeAtPosition(SinglyLinkedListNode* head, int data, int position) { SinglyLinkedListNode *temp=new SinglyLinkedListNode(data); SinglyLinkedListNode *nh= head; for(int i=0;i<position-1;i++) { nh=nh->next; } SinglyLinkedListNode *t; t=nh->next ; nh->next=temp; temp->next=t; return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →
In c++