You are viewing a single comment's thread. Return to all comments →
Adding solution in Java:
static SinglyLinkedListNode insertNodeAtTail(SinglyLinkedListNode head, int data) { SinglyLinkedListNode temp = new SinglyLinkedListNode(data);
if(head==null) return temp; SinglyLinkedListNode current = head; while(current.next!=null) current = current.next; current.next = temp; return head; }
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
Adding solution in Java:
static SinglyLinkedListNode insertNodeAtTail(SinglyLinkedListNode head, int data) { SinglyLinkedListNode temp = new SinglyLinkedListNode(data);