You are viewing a single comment's thread. Return to all comments →
func insertNodeAtPosition(llist *SinglyLinkedListNode, data int32, position int32) *SinglyLinkedListNode { // find pos currNode := llist for position > 1 { position-- currNode = currNode.next } // insert node newNode := &SinglyLinkedListNode{data: data} newNode.next = currNode.next currNode.next = newNode return llist }
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 →
Go solution