You are viewing a single comment's thread. Return to all comments →
Here is my csharp solution:
static SinglyLinkedListNode insertNodeAtTail(SinglyLinkedListNode head, int data) { SinglyLinkedListNode curr = head; SinglyLinkedListNode n1 = new SinglyLinkedListNode(data); if(head == null) { head = n1; Console.WriteLine(head.data); } else { if(curr.next == null) head.next = n1; else { while(curr.next != null) curr = curr.next; curr.next = n1; } Console.WriteLine(head.next.data); } return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
Here is my csharp solution: