You are viewing a single comment's thread. Return to all comments →
My Solution
SinglyLinkedListNode n=new SinglyLinkedListNode(data);
SinglyLinkedListNode node=head; while(position!=1 && node.next!=null) { node=node.next; position--; } SinglyLinkedListNode temp=node.next; node.next=n; n.next=temp; 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 →
My Solution
SinglyLinkedListNode n=new SinglyLinkedListNode(data);