@@ -0,0 +1,1867 @@
+package data_structures.linked_lists;%0D%0A%0D%0A/*%0D%0A * Problem Statement:%0D%0A * Youre given the pointer to the head node of a linked list, an integer to add%0D%0A * to the list and the position at which the integer must be inserted. Create a%0D%0A * new node with the given integer, insert this node at the desired position and%0D%0A * return the head node. A position of 0 indicates head, a position of 1%0D%0A * indicates one node away from the head and so on. The head pointer given may%0D%0A * 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, int position)%0D%0A * method which takes three arguments - the head of the linked list, the integer%0D%0A * to insert and the position at which the integer must be inserted. You should%0D%0A * NOT read any input from stdin/console. position will always be between 0 and%0D%0A * the number of the elements in the list (inclusive).%0D%0A * %0D%0A * Output Format:%0D%0A * Insert the new node at the desired position and return the head of the%0D%0A * updated linked list. Do NOT print anything to stdout/console.%0D%0A * %0D%0A * Sample Input: %0D%0A * NULL, data = 3, position = 0%0D%0A * 3 --%3E NULL, data = 4, position = 0%0D%0A * %0D%0A * Sample Output: %0D%0A * 3 --%3E NULL%0D%0A * 4 --%3E 3 --%3E NULL%0D%0A */%0D%0Apublic class InsertNodeAtSpecificPositionInLinkedList %7B%0D%0A%0D%0A%09Node InsertNth(Node head, int data, int position) %7B%0D%0A%0D%0A%09%09Node newNode = new Node();%0D%0A%09%09newNode.data = data;%0D%0A%09%09newNode.next = null;%0D%0A%0D%0A%09%09if (head == null) %7B%0D%0A%09%09%09head = newNode;%0D%0A%09%09%09return head;%0D%0A%09%09%7D else if (position == 0) %7B%0D%0A%09%09%09newNode.next = head;%0D%0A%09%09%09head = newNode;%0D%0A%09%09%09return head;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09Node pointer = head;%0D%0A%09%09%09int currentPos = 0;%0D%0A%0D%0A%09%09%09while (currentPos %3C (position - 1) && pointer.next != null) %7B%0D%0A%09%09%09%09pointer = pointer.next;%0D%0A%09%09%09%09currentPos++;%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09newNode.next = pointer.next;%0D%0A%09%09%09pointer.next = newNode;%0D%0A%09%09%09return head;%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

Add InsertNodeAtSpecificPositionInLinkedList