You are viewing a single comment's thread. Return to all comments →
My Go(Golang) solution
var node *SinglyLinkedListNode node = &SinglyLinkedListNode{data, nil} var currentNode *SinglyLinkedListNode = llist var prevNode *SinglyLinkedListNode = nil for i := 0; int32(i) <= position; i++{ if int32(i) == position{ prevNode.next = node node.next = currentNode } else{ prevNode = currentNode currentNode = currentNode.next } } 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 →
My Go(Golang) solution