You are viewing a single comment's thread. Return to all comments →
This is the improved code
def insertNodeAtPosition(head, data, position): n=head if position==0: head=SinglyLinkedListNode(data) head.next=n else: for i in range(position-1): n=n.next n_next=n.next n.next=SinglyLinkedListNode(data) n.next.next=n_next 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 →
This is the improved code