Insert a node at a specific position in a linked list

  • + 0 comments

    def insertNodeAtPosition(head, data, position): # Write your code here newnode=SinglyLinkedListNode(data) current=head if head is not None: count=1 while current.next: if count==position: newnode.next=current.next current.next=newnode count+=1 current=current.next return head