You are viewing a single comment's thread. Return to all comments →
Thanks your explanation cleared my doubt about how the test case is working.
Here is the python version of it if anyone is interested.
def InsertNth(head, data, position): if not position == 0: _head = head current_position = 1 while(position - current_position>0): _head = _head.next current_position+=1 if _head.next is None: _head.next = Node(data,None) return head else: prev = _head.next _head.next = Node(data,prev) return head else: return Node(data,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 →
Thanks your explanation cleared my doubt about how the test case is working.
Here is the python version of it if anyone is interested.