You are viewing a single comment's thread. Return to all comments →
simplest python solution:
def insertNodeAtPosition(llist, data, position): new_node = SinglyLinkedListNode(data) curr = llist prev = llist for i in range(position): prev = curr curr = curr.next prev.next = new_node new_node.next = curr 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 →
simplest python solution: