You are viewing a single comment's thread. Return to all comments →
Here's a Python 3 code with O(1) time Complexity (Correct me if I'm wrong):
def insertNodeAtHead(llist, data): newNode = SinglyLinkedListNode(data) if llist is None: llist = newNode return llist else: newNode.next = llist llist = newNode return llist
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at the head of a linked list
You are viewing a single comment's thread. Return to all comments →
Here's a Python 3 code with O(1) time Complexity (Correct me if I'm wrong):