You are viewing a single comment's thread. Return to all comments →
Here is my version.
def InsertNth(head, data, position): if head is None or position <= 0: return Node(data, head) else: probe = head while position > 1 and probe.next is not None: probe = probe.next position -= 1 probe.next = Node(data, probe.next) return head
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →
Here is my version.