You are viewing a single comment's thread. Return to all comments →
May be test cases are changed, following code passes all test cases:
def InsertNth(head, data, position): if position == 0: head = Node(data, head) else: cur = head for _ in range(position-1): cur = cur.next cur.next = Node(data, cur.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 →
May be test cases are changed, following code passes all test cases: