We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Insert a node at the head of a linked list
Insert a node at the head of a linked list
Sort by
recency
|
988 Discussions
|
Please Login in order to post a comment
On the C# variant you have an error in line 83 that prevents code to be evaluated. PrintSinglyLinkedList(llist->head, "\n", textWriter); I think it should be: PrintSinglyLinkedList(llist_head, "\n", textWriter); Not all the time java code works in C# :D
Java Solution we want to insert the node head of the sll(sll Node,int data) { sll new head= new sllNode(data); if(list!=NULL) { Node.next=list return new head }
Java Solution we want to insert the node head of the sll(sll Node,int data) { sll new head= new sllNode(data); if(list!=NULL) { Node.next=list return new head }
My Java solution with o(1) time complexity and o(1) space complexity:
python 3