@@ -0,0 +1,1437 @@
+package data_structures.linked_lists;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * You are given the pointer to the head node of a linked list and an integer to%0D%0A * add to the list. Create a new node with the given integer. Insert this node%0D%0A * at the tail of the linked list and return the head node. The given head%0D%0A * pointer may be null, meaning that the initial list is empty.%0D%0A * %0D%0A * Input Format:%0D%0A * You have to complete the Node* Insert(Node* head, int data) method. It takes%0D%0A * two arguments: the head of the linked list and the integer to insert. You%0D%0A * should not read any input from the stdin/console.%0D%0A * %0D%0A * Output Format:%0D%0A * Insert the new node at the tail and just return the head of the updated%0D%0A * linked list. Do not print anything to stdout/console.%0D%0A * %0D%0A * Sample Input: %0D%0A * NULL, data = 2%0D%0A * 2 --%3E NULL, data = 3%0D%0A * %0D%0A * Sample Output: %0D%0A * 2 --%3ENULL%0D%0A * 2 --%3E 3 --%3E NULL%0D%0A */%0D%0Apublic class InsertNodeAtTailOfLinkedList %7B%0D%0A%0D%0A%09Node Insert(Node head, int data) %7B%0D%0A%09%09// This is a %22method-only%22 submission.%0D%0A%09%09// You only need to complete this method.%0D%0A%09%09if (head == null) %7B%0D%0A%09%09%09Node newNode = new Node();%0D%0A%09%09%09newNode.data = data;%0D%0A%09%09%09newNode.next = null;%0D%0A%09%09%09head = newNode;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09Node pointer = head;%0D%0A%0D%0A%09%09%09while (pointer.next != null) %7B%0D%0A%09%09%09%09pointer = pointer.next;%0D%0A%09%09%09%7D%0D%0A%09%09%09Node newNode = new Node();%0D%0A%09%09%09newNode.data = data;%0D%0A%09%09%09newNode.next = null;%0D%0A%09%09%09pointer.next = newNode;%0D%0A%09%09%7D%0D%0A%09%09return head;%0D%0A%09%7D%0D%0A%7D

Add InsertNodeAtTailOfLinkedList